note 29287 deleted from reserved.variables by jsheets
| From: | jsheets@php.net | Date: | Sat, 08 Feb 2003 17:26:28 +0000 |
| Subject: | note 29287 deleted from reserved.variables by jsheets | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-43619@lists.php.net to get a copy of this message | ||
I found a little bug in processing forms data.
In case of <SELECT MULTIPLE NAME="field"> browser returns form data string where the
field name may be repeated several times: field=1&field=2& ... &field=10 When your
script tries to handle this using $HTTP_POST_VARS or $HTTP_GET_VARS you'll see only the last
value : field=10 as both arrays are associative.
To handle MULTIPLE properly you need to parse the query string yourself:
If the form uses GET:
/*properly handles multiple fields*/
$thisQuery = $_SERVER["QUERY_STRING"];
$queryArray = explode("&",$thisQuery);
foreach ($queryArray as $queryItem)
{
$querySegment = explode("=",$queryItem);
array_push ($this->valuestack, $querySegment[1]);
array_push ($this->keystack,$querySegment[0]);
}
If the form uses POST:
you should (probably) add: always_populate_raw_post_data = On to php.ini and parse
$_SERVER["HTTP_RAW_POST_DATA"] accordingly.
Hope it helps someone :).