|
Posted by Johnny on 09/27/06 13:02
"Girish" <girishbhat6620@gmail.com> wrote in message
news:1159359055.574104.168360@h48g2000cwc.googlegroups.com...
> Hi Everyone,
>
> I am passing a form to a php script for further processing.
>
>
> I am able to retrieve the last value set for that given form variable
> using
> $variable=$_REQUEST['form_variable'];
>
>
> My question is, what is the Php way of retrieving all the values passed
> for the same form variable?
>
> For example, if the php script is called with a syntax like
>
>
http://xxxx/get_variables.php?form_variable=value1&form_variable=value2&form
_variable=variable
>
>
> , how do I iterate through all the values that form_variable has been
> set to?
>
> Thanks and regards,
> Girish
>
if register_globals is ON then the variables are already set by php (which,
BTW, can cause all kinds of unexpected grief when html tag names end up as
php vars).
You can test the results by doing this:
<?php
if (!empty($_GET)) { # can't use !empty($_REQUEST) as it always has
something
echo "before foreach a=".$a.",b=".$b.",c=".$c."<br />"; // if
register_globals is on these are already set
# if register_globals is OFF this will set all request vars
foreach ($_REQUEST as $key => $value){
$$key = $value;
}
echo "after foreach a=".$a.",b=".$b.",c=".$c."<br />";
}
else {
echo <<<FORM
<form method="get" action="{$_SERVER['PHP_SELF']}">
<input type="text" name="a" />
<input type="text" name="b" />
<input type="text" name="c" />
<input type="submit" />
</form>
FORM;
}
?>
but be aware that $_REQUEST has extra stuff in it.
[Back to original message]
|