Req #51633 [Com]: Accept "post" input of multiple fields with the same name
Edit report at https://bugs.php.net/bug.php?id=51633&edit=1
ID: 51633
Comment by: gerardnico at gmail dot com
Reported by: bart at tremby dot net
Summary: Accept "post" input of multiple fields with the same
name
Status: Wont fix
Type: Feature/Change Request
Package: HTTP related
Operating System: Ubuntu
PHP Version: 5.2.13
Block user comment: N
Private report: N
New Comment:
Why o why ?
We are in 2021 and this is so well known that I bang my head around it and discover that this is
just because there is someone who has implemented it as a map and another one who don't dare to
modify it in the next version.
Now my form needs to know the server technology before sending multipart post data.
Backward, awkward.
Not surprising that everybody is using Json.
Previous Comments:
------------------------------------------------------------------------
[2011-01-28 01:09:44] bart at tremby dot net
Could you comment the second suggestion I made?
That is, why is php://input unavailable when data is sent as multipart/form-data?
------------------------------------------------------------------------
[2011-01-28 00:44:15] aharvey@php.net
This would absolutely shred backward compatibility: there's already a
documented way of accomplishing this with [], and although HTML allows
multiple values regardless of name, PHP doesn't, and this behaviour is
well established.
Closing won't fix.
------------------------------------------------------------------------
[2011-01-27 12:23:27] bart at tremby dot net
That workaround is fine for data sent as application/x-www-form-urlencoded but won't work if
the data is sent as multipart/form-data.
------------------------------------------------------------------------
[2011-01-27 12:19:03] t33th4n at gmail dot com
In the meantime, i made a workaround of the problem
process_browser_params(); must be called in the very beginning of things.
After this, $_NEWREQUEST will containt both get and post parameters.
function process_browser_params()
{
GLOBAL $_NEWREQUEST;
$datas = explode('&', file_get_contents("php://input"));
for($i=0;$i<count($datas);$i++)
{
$datas[$i] = explode('=', $datas[$i]);
}
unset($data);
for($i=0;$i<count($datas);$i++)
{
if ((count($data)>0) && (array_key_exists($datas[$i][0], $data)))
{
$data[$datas[$i][0]] = $data[$datas[$i][0]].",".urldecode($datas[$i][1]);
} else
{
$data[$datas[$i][0]] = urldecode($datas[$i][1]);
}
}
$_NEWREQUEST = $data;
}
Enjoy
------------------------------------------------------------------------
[2011-01-27 11:16:01] t33th4n at gmail dot com
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
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=51633
--
Edit this bug report at https://bugs.php.net/bug.php?id=51633&edit=1
Thread (7 messages)