Bug #10502 Updated: parsing for HTTP_POST_VARS drops duplicates

From: Date: Tue, 09 Jul 2002 15:26:24 +0000
Subject: Bug #10502 Updated: parsing for HTTP_POST_VARS drops duplicates
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-13616@lists.php.net to get a copy of this message
ID: 10502 Updated by: markonen@php.net Reported By: mk@adio.com -Status: Open +Status: Closed Bug Type: Feature/Change Request Operating System: Linux PHP Version: 4.0.4pl1 New Comment: $HTTP_RAW_POST_DATA or $_SERVER["HTTP_RAW_POST_DATA"] with the new superglobals is where POST data is. With that, cynic's example can be made to work with POST as well. Closing this. Previous Comments: ------------------------------------------------------------------------ [2001-04-26 02:04:42] cynic@php.net open again, this won't work for POSTs... thx to Zak. ------------------------------------------------------------------------ [2001-04-26 01:49:58] cynic@php.net this is by design. take a look at this (you'll have to edit it): function _QueryString() { $qsstr = '' ; $qsarr = array() ; $QS = strtr( $GLOBALS['HTTP_SERVER_VARS']["QUERY_STRING"] , array( '[' => '' , ']' => '' ) ) ; $QS = explode( '&' , $QS ) ; foreach( $QS as $q ) { $eq = strpos( $q , '=' ) ; if( false === $eq ) { $var = $q ; $val = '' ; } else { $var = substr( $q , 0 , $eq ) ; $val = substr( $q , $eq+1 ) ; } if( isset( $qsarr[$var] ) ) { $qsarr[$var] = array_merge( (array) $qsarr[$var] , array( $var => $val ) ) ; } else { $qsarr[$var] = $val ; } $qsstr .= "$var=$val&" ; } $this->_QueryString = substr( $qsstr , 0 , -1 ) ; $this->QueryString = $qsarr ; } ------------------------------------------------------------------------ [2001-04-26 01:41:16] mk@adio.com Parsing of a POST drops duplicate variables unless those variables have "[]". It's a few lines in Perl to get it, but I need to stay inside PHP.... is there anywhere that the equivalent of thePerl $form field below: if ( $ENV{'REQUEST_METHOD'} eq "POST" ) { read(STDIN,$form, $ENV{'CONTENT_LENGTH'}); is available in a PHP session... I need the whole unparsed line, so that I can manage transforming duplicates into an array. I have a situation where a check-box coded by someone else I have no control over is sending multiple values with the same field name. Code for parsing into HTTP_POST_VARS discards all but the last name value pair in the Parse stage because, unfortunately the field is not ending in "[]" in the FORM. ... thoughts. mk@adio.com ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=10502&edit=1

« previous php.bugs (#13616) next »