Bug #71549 [Nab]: PHP only parses one value from <select multiple> HTML controls
| From: | requinix@php.net | Date: | Mon, 08 Feb 2016 02:05:48 +0000 |
| Subject: | Bug #71549 [Nab]: PHP only parses one value from <select multiple> HTML controls | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-199104@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71549&edit=1
ID: 71549
Updated by: requinix@php.net
Reported by: php2016 at hypertwins dot org
Summary: PHP only parses one value from <select multiple>
HTML controls
Status: Not a bug
Type: Bug
Package: Unknown/Other Function
Operating System: Ubuntu 14.04.3 LTS
PHP Version: Next Minor Version
Block user comment: N
Private report: N
New Comment:
If you have in mind a change you'd like to see in the documentation then you can submit a patch
yourself pretty easily: go to whichever page and click the Edit link in the top-right corner to be
taken to an online editor for the doc's XML sources.
Previous Comments:
------------------------------------------------------------------------
[2016-02-08 01:49:58] requinix@php.net
So something in the documentation saying to use arrays with form variables to get values from a
multiple select input? Perhaps some example code too?
http://php.net/manual/en/language.variables.external.php#example-124
and the couple sentences before it
------------------------------------------------------------------------
[2016-02-08 01:38:16] php2016 at hypertwins dot org
You say it's not a bug, but don't mention how this is consistent with intended or
documented behavior.
You say check the manual, but the manual doesn't give any information about the formatting of
<select> data in the $_POST array (at least, not that I could find, and I spent at least an
hour trying to figure this one out).
This is still a bug -- though possibly what needs fixing is the manual.
------------------------------------------------------------------------
[2016-02-08 01:22:21] requinix@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
http://php.net/manual/en/faq.html.php#faq.html.select-multiple
------------------------------------------------------------------------
[2016-02-08 00:40:44] php2016 at hypertwins dot org
Description:
------------
This is in PHP 5.5.9-1ubuntu4.14 (not listed in the PHP version drop-down).
Full phpinfo here: http://vbz.net/phpinfo.php
The test script is currently running here: http://vbz.net/test/phpbug.php
The problem is that <select multiple> controls can return multiple values, but PHP seems to
ignore all but the last one. When multiple values are detected, PHP should put them in an array. As
it is, <select multiple> input via $_POST, $_GET, or $_REQUEST is unusable.
This problem does seem to be the same as bug #1117, but:
(a) the only response is that "This is entry #5.9 in the FAQ", and the FAQ is no longer
numbered that way (it's in multiple pages now, and the 5th FAQ page is about
"installation"), and...
(b) that report is from 1999 -- surely this problem has been more properly addressed since then...?
Test script:
---------------
It's 24 lines, so... here: http://htyp.org/User:Woozle/PHP_multi-select_bug
Expected result:
----------------
The script emits text explaining the problem. $_POST should contain something like this:
Array
(
[test_select] => (array) : 3 elements
[1] => (string) : 'on'
[2] => (string) : 'on'
[3] => (string) : 'on'
[btnTest] => Yes, this button. Press me.
)
The exact format of the array within the [test_select] element isn't critical, though I believe
the format shown would be consistent with how checkboxes are handled. What does matter is that all
three values are included, rather than just one of them.
Actual result:
--------------
$_POST contents:
Array
(
[test_select] => 3
[btnTest] => Yes, this button. Press me.
)
Raw POST
header:[test_select=1&test_select=2&test_select=3&btnTest=Yes%2C+this+button.+Press+me.]
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71549&edit=1