From: rveetil at google dot com
Operating system: Windows XP
PHP version: 5.2.6
PHP Bug Type: Arrays related
Bug description: form variable for muliple select returns only single value
Description:
------------
My configuration is Window XP/Apache 6.0.14/PHP 5.2.6. Browser tested-
IE6, FireFox 3.0, Google Chrome
The multiple select of the form variable always returns a single value in
an array (always returns the top one in the list).
Pick options: Option A
Option B
Option C
Option D
I've selected Option B, Option C & Option D
Reproduce code:
---------------
<?php
if ($_POST) {
echo '<pre>';
echo htmlspecialchars(print_r($_POST, true));
echo '</pre>';
}
$test=$_POST['test'];
if ($test){
foreach ($test as $t){echo 'You selected :',$t,'<br />';}
}
?>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
Pick options:
<select name="test[]" multiple >
<option value="A"> Option A</option>
<option value="B"> Option B</option>
<option value="C"> Option C</option>
<option value="D"> Option D</option>
</select>
<input type="submit" name="submit">
</form>
Expected result:
----------------
Array
(
[test] => Array
(
[0] => B
[1] => C
[2] => D
)
[submit] => Submit Query
)
You selected :B
You selected :C
You selected :D
Actual result:
--------------
Array
(
[test] => Array
(
[0] => B
)
[submit] => Submit Query
)
You selected :B
--
Edit bug report at http://bugs.php.net/?id=46288&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=46288&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=46288&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=46288&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=46288&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=46288&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=46288&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=46288&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=46288&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=46288&r=support
Expected behavior: http://bugs.php.net/fix.php?id=46288&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=46288&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=46288&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=46288&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46288&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46288&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=46288&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=46288&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=46288&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=46288&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=46288&r=mysqlcfg