|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-01-16 15:26 UTC] ivanpisa at dfm dot ffclrp dot usp dot br
I'm using PHP 4.3.0 as ISAPI in 2 WinXP machines, running Apache 2.0.43. PHP was installed at same folders and I'm using the same PHP.INI. In machine 1, everything works great. In machine 2, everything works great too BUT when I'm using checkbox inside form posting: echo "<form method=post action=form2.php>"; echo "<br>Are married?"; echo "<input type=checkbox name=married value='s'>"; echo "</form>"; the form2.php is: <? echo "<html><body>"; $married = $HTTP_POST_VARS["married"]; echo "married = ".$married; echo "</body></html>"; ?> the response is: Notice: Undefined index: married in form2.php on line 2 In machine 1, forms with checkbox are working great, but in machine 2, it doesn't. Any ideas?? PHP.INI is the same, global_variables are OFF. Thanks in advance Ivan Pisa PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 14:00:01 2025 UTC |
First, thanks for your attention. a) I'm running the same script in other machine, and it's passing NULL ("") string. I suppose the other machine, with the same configuration, should have the same behavior. b) Do I have to create the variable? Again, it's running in other machine with no problems. And all of my variables are created in the moment I need them. Did I miss something about PHP? c) I'll test. d) You are right, sorry, I mean register_globals is off e) I'll read.Same problem with PHP 5.1.4, Windows XP and Xampp 1.5.3a. The problem is especially: How to create a CSV file from post data without explicitely handling checkbox fields by their names if some checkbox fields "vanish"? You will get an unusable CSV file, because the order of the fields gets mismatched. Workaround: Inside the form, create checkboxes, which always are checked, but hidden for the user (using CSS), like this: <input style="display:none" type="checkbox" name="test_chk[]" value="phpbug" checked> <input class="checkbox" type="checkbox" name="test_chk[]" value="TRUE"> Within a loop ?foreach ($_POST as $key=>$value)? through the post data, you then can do sth. like this: if (strpos($key,"_chk")) { if (isset($_POST[$key][1])) {$v='TRUE';} else {$v='FALSE';}; } Regards, Maike