Fw: [PHP-DEV] PHP 4.0 Bug #7934: HTTP_POST_VARS unable to handle same key multiple times

From: Date: Wed, 22 Nov 2000 23:51:59 +0000
Subject: Fw: [PHP-DEV] PHP 4.0 Bug #7934: HTTP_POST_VARS unable to handle same key multiple times
Groups: php.dev 
Request: Send a blank email to php-dev+get-38954@lists.php.net to get a copy of this message
I don't know if you're suggesting that PHP should be modified, but if you want that kind of functionality, it *is* available. Just use <input type=checkbox name="FORM_key[]" value="2"> <input type=checkbox name="FORM_key[]" value="8"> <input type=checkbox name="FORM_key[]" value="19"> and a print_r($FORM_key) would then print: Array ( [0] => 2 [1] => 8 [2] => 19 ) I hope that's what you wanted. - Jon ----- Original Message ----- From: <bzeeb+php@zabbadoz.net> To: <php-dev@lists.php.net> Sent: Wednesday, November 22, 2000 2:03 PM Subject: [PHP-DEV] PHP 4.0 Bug #7934: HTTP_POST_VARS unable to handle same key multiple times From: bzeeb+php@zabbadoz.net Operating system: FreeBSD PHP version: 4.0.3 PHP Bug Type: Variables related Bug description: HTTP_POST_VARS unable to handle same key multiple times Using p.ex. function from FAQ 7.1 to read HTTP_POST_VARS one is unable to handle/see all key-value-pairs when key is the same for multiple values. I did not find any way to see all pairs (well one might define an array as name but that is not what CGI standard expects I think). p.ex. having something like this in a HTML form: <input type=checkbox name="FORM_key" value="2"> <input type=checkbox name="FORM_key" value="8"> <input type=checkbox name="FORM_key" value="19"> would only result in: FORM_key -> 19 sizeof($HTTP_POST_VRS) = 1 instead of FORM_key -> 2 FORM_key -> 8 FORM_key -> 19 where sizeof would return 3. This is most likely caused by using some kind of associative array instead of using indexes. I did not manage to solve this by using other array f()s. I do not have time to look at the source code - sorry. A simple dirty quick hack perl-script shows you that one does get all the three values: --- snipp --- #!/usr/bin/perl printf("Content-Type: text/html\n\n"); if ($ENV{'CONTENT_LENGTH'} > 0) { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); printf("\nPOST-Buffer (raw):<br>\n"); printf("%s\n", $buffer); printf("\nPOST-Buffer (split up):<br>\n"); foreach $pair (@pairs) { printf("%s<br>\n", $pair); } } else { printf("NO HTTP_POST_VARs -> nothing to do here<br>\n"); } # End; --- snipp --- -- Edit Bug report at: http://bugs.php.net/?id=7934&edit=1 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net For additional commands, e-mail: php-dev-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.dev (#38954) next »