You are here: Re: Retrieving the multiple values set by a form « PHP Programming Language « IT news, forums, messages
Re: Retrieving the multiple values set by a form

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.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация