php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71549 PHP only parses one value from <select multiple> HTML controls
Submitted: 2016-02-08 00:40 UTC Modified: 2016-02-08 02:05 UTC
From: php2016 at hypertwins dot org Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: Next Minor Version OS: Ubuntu 14.04.3 LTS
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php2016 at hypertwins dot org
New email:
PHP Version: OS:

 

 [2016-02-08 00:40 UTC] 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.]

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-02-08 01:22 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2016-02-08 01:22 UTC] 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 01:38 UTC] 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:49 UTC] 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 02:05 UTC] requinix@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 23:01:28 2024 UTC