|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-11-27 11:53 UTC] jani@php.net
[2008-12-05 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 18:00:02 2025 UTC |
Description: ------------ Under PHP 5.2.6 the $_POST variable behaves differently for html forms with 1 input field than forms with more than one. When there is only 1 field in a form the result of $_POST['field_name'] gets returned as: FIELD_VALUEfield_name=FIELD_VALUE With multiple form fields the result is returned as you would expect: FIELD_VALUE Reproduce code: --------------- <html> <head> <title>PHP 5.2.6 Form $_POST Problem</title> </head> <body> <?php if ($_POST) { print("Contents of \$_POST variable<br /><br />\n"); $count = count($_POST); print("$_POST contains $count item(s).<br />\n"); foreach (array_keys($_POST) as $key) { $$key = $_POST[$key]; print "$key is '${$key}'<br />"; } } ?> <hr width="200" align="left"/> Form with 1 input field<br /><br /> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> Field1: <input type="text" name="field1" value="value1"/><br /> <input type="submit" value="Add" /> </form> <br /> <hr width="200" align="left"/> Form with 2 input fields<br /><br /> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> Field2: <input type="text" name="field2" value="value2" /><br /> Field3: <input type="text" name="field3" value="value3" /><br /> <input type="submit" value="Add" /> </form> </body> </html> Expected result: ---------------- ... click 1st Add button ... Contents of $_POST variable Array contains 1 item(s). field1 is 'value1' ... click 2nd Add button ... Contents of $_POST variable Array contains 2 item(s). field2 is 'value2' field3 is 'value3' Actual result: -------------- ... click 1st Add button ... Contents of $_POST variable Array contains 1 item(s). field1 is 'value1field1=value1' ... click 2nd Add button ... Contents of $_POST variable Array contains 2 item(s). field2 is 'value2' field3 is 'value3' It works properly for PHP 5.2.4 on another server.