note 29287 added to reserved.variables
| From: | teos at centum dot pl | Date: | Sat, 08 Feb 2003 15:00:13 +0000 |
| Subject: | note 29287 added to reserved.variables | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-43614@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 :).
--
http://www.php.net/manual/en/reserved.variables.php
http://master.php.net/manage/user-notes.php?action=edit+29287
http://master.php.net/manage/user-notes.php?action=delete+29287
http://master.php.net/manage/user-notes.php?action=reject+29287