From: [EMAIL PROTECTED] Operating system: Windows 2000 Pro PHP version: 4.1.0 PHP Bug Type: Variables related Bug description: $HTTP_POST_VARS not finding all posted variables
- Win2K Pro, running Apache 1.3.22 (standard Win32 setup) - PHP 4.1.0, Win32 Binaries -- no changes to ini file (except "include_path =" and "SMTP =" - WHAT I DID: I created a simple html form with the "POST" method: <html> <body> <form action="test1.php" method="post"> <input type="radio" name="radiobutton" value="True">True <input type="radio" name="radiobutton" value="False">False <input type="submit" name="submitbutton" value="Submit"> </form> </body> </html> Next I created "test1.php" to receive those posted variables (as you can see I tried several methods of checking them): <? foreach ($HTTP_POST_VARS as $var => $value) { echo "$var = $value<br>\n"; } echo "<P>Values submitted via POST method:<br>"; reset ($HTTP_POST_VARS); while (list ($key, $val) = each ($HTTP_POST_VARS)) { echo "$key => $val<br>"; } ?> - WHAT I WANTED TO HAPPEN: I wanted to use the $HTTP_POST_VARS array to validate the form. If the end user forgets to select one of the radio button options, that should show up in $HTTP_POST_VARS as a variable with a "" value, which would allow me to post a validation error message to the user. - WHAT ACTUALLY HAPPENED: If the end user forgets to select one of the radio options, the posted variable doesn't show up in $HTTP_POST_VARS !! The output of the php script is: // begin test1.php output (with no radio button selected): submitbutton = Submit Values submitted via POST method: submitbutton => Submit // end test1.php output If one of the buttons is pre-selected, it will show up as a variable in the $HTTP_POST_VARS. Here is the output: //begin test1.php output (with radio button selected): radiobutton = False submitbutton = Submit Values submitted via POST method: radiobutton => False submitbutton => Submit // end test1.php output (with radio button pre-selected) -WHY THIS IS A SERIOUS PROBLEM: As I'm sure you can imagine, this makes it impossible to create a generic validation script that is capable of validating radio buttons. If I create a simple $radiobutton variable (the same name as the form input), It will work to validate the form if the user has not remembered to select a radio button. But this will require me to manually validate radio buttons in my script, rather than being able to create and use a generic validation script. I've created a generic script in ASP that uses the "request.form" method to validate all form fields and it works properly with radio buttons. Also, I've tested the $HTTP_POST_VARS array with all other input types, and it finds all other posted variables, even if they are blank. What can I do? -- Edit bug report at: http://bugs.php.net/?id=14674&edit=1 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]