Edit report at http://bugs.php.net/bug.php?id=51633&edit=1
ID: 51633 Comment by: t33th4n at gmail dot com Reported by: bart at tremby dot net Summary: Accept "post" input of multiple fields with the same name Status: Open Type: Feature/Change Request Package: HTTP related Operating System: Ubuntu PHP Version: 5.2.13 Block user comment: N Private report: N New Comment: Source is: <form method="get"> <select name="something" multiple size="2"> <option selected="selected" value="1">One</option> <option selected="selected" value="2">Two</option> <option value="3">Three</option> </select> <input type="submit" value="Try it" /> </form> Expected result: Multiple values for same key, possibly in an array or comma separated string (i would prefer this and more easy to implement in php core i think :). Current result: In browser address, the values appears, but php does not provides those values. PHP Version: 5.3.5 Apache version: 2.2.11.0 Previous Comments: ------------------------------------------------------------------------ [2010-04-22 14:49:57] bart at tremby dot net Description: ------------ I currently have to handle post data which is submitted as multipart/form-data and has multiple fields with the same name. The latter means I can't use $_POST (I only get the last of the fields with the same name) and the former means I can't use php://input or $HTTP_RAW_POST_DATA. According to http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.1.2.3 it's fine to have multiple fields with the same name. The obvious answer to my problem would be to append "[]" to the end of the field names so that PHP parses them into an array. But in this case I don't have control over the data source. And in fact the HTML4.01 specification says at http://www.w3.org/TR/html4/types.html#h-6.2 'ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".")' So putting "[]" at the end of field names is actually against the HTML specification so it seems bad to require them. So I have two suggestions here (let me know if I should file a separate request for the latter): 1. Whenever there is more than one field with the same name make an array, rather than only when the field name ends in "[]". This could of course cause issues with existing scripts which are being passed multiple values when they don't expect it or which are relying on a later field with the same name overwriting an earlier one, but I would wager that this is rare. 2. I could work around this right now if I could get php://input or $HTTP_RAW_POST_DATA, only they're not available since it's multipart/form-data. Why shouldn't the raw post data be available when it's encoded this way? It'd make it possible to work around broken post data (in this case as far as I can see the post data is fine according to the spec but I can imagine having to deal with actual broken data). ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=51633&edit=1