|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2000-11-22 17:03 UTC] bzeeb+php at zabbadoz dot net
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 ---
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 21:00:01 2025 UTC |
to chrisrivera@chrisrivera.com: by giving the [] you specify that you *want* an array while creating one auto-magicaly whenever multiple values exists may confuse form processing code as input variables may be string or array depending on number of selections made to olivierdsm@hotmail.com: this will do the trick for you: "... IN (".join(",",$inmailtoupdate).") " (but make sure $inmailtoupdate is not empty() before you do so) please direct further questions to the php-general mailing list as we are no longer talking about bugs hereOr you can use the feature of JavaScript that, *by* *definition* a.b is identical to a['b'] so you could refer to document.myform['mycheckbox[]'].length