ID:               46694
 Updated by:       [EMAIL PROTECTED]
 Reported By:      web at mshearn dot com
-Status:           Open
+Status:           Feedback
-Bug Type:         Variables related
+Bug Type:         *General Issues
 Operating System: RedHat Linux 2.4.21 x86_64
 PHP Version:      5.2.6
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

I can't reproduce. If the snapshot doesn't fix it, provide a bit more
information of your setup, f.e. what SAPI and webserver you're using.


Previous Comments:
------------------------------------------------------------------------

[2008-11-27 03:23:10] web at mshearn dot com

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.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=46694&edit=1

Reply via email to