Re: Retrieving the multiple values set by a form
- From: "Johnny" <removethis.huuanito@xxxxxxxxxxx>
- Date: Wed, 27 Sep 2006 06:02:22 -0700
"Girish" <girishbhat6620@xxxxxxxxx> wrote in message
news:1159359055.574104.168360@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi Everyone,http://xxxx/get_variables.php?form_variable=value1&form_variable=value2&form
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
_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.
.
- References:
- Retrieving the multiple values set by a form
- From: Girish
- Retrieving the multiple values set by a form
- Prev by Date: Re: Retrieving the multiple values set by a form
- Next by Date: XP Development Environment
- Previous by thread: Re: Retrieving the multiple values set by a form
- Next by thread: Re: Retrieving the multiple values set by a form
- Index(es):
Relevant Pages
|