From:             web at mshearn dot com
Operating system: RedHat Linux 2.4.21 x86_64
PHP version:      5.2.6
PHP Bug Type:     Variables related
Bug description:  $_POST variable behaves differently for form with 1 input 
than multiple

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 bug report at http://bugs.php.net/?id=46694&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=46694&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=46694&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=46694&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=46694&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=46694&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=46694&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=46694&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=46694&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=46694&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=46694&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=46694&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=46694&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=46694&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=46694&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=46694&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=46694&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=46694&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=46694&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=46694&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=46694&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=46694&r=mysqlcfg

Reply via email to