Re: Retrieving the multiple values set by a form



"Girish" <girishbhat6620@xxxxxxxxx> wrote in message
news:1159359055.574104.168360@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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

Hi Girish,

In the example you have given, which equates to a Get, the variables will
indeed overwrite each other with only the last value surviving, as stated by
lorento.

You can however create an array by suffixing the variable name (in the HTML
form) this
<input name='inp[0]' type='hidden' value='first value'>
<input name='inp[1]' type='hidden' value='second value'>
<input name='inp[2]' type='hidden' value='third value'>

once this is received by your PHP script the values may be retrieved :

$myArray = $_REQUEST('ip'); // note no subscripts required

$myArray['0'] will contain 'first value', $myArray['1'] the second value,
and so on

BTW Register globals should be OFF on any production machine so there is
little point in having it on in a development machine.

HTH

Ron


.



Relevant Pages

  • Re: Retrieving the multiple values set by a form
    ... Ron Barnett wrote: ... 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 ... BTW Register globals should be OFF on any production machine so there is little point in having it on in a development machine. ...
    (comp.lang.php)
  • Re: [PHP] retrieve POST body?
    ... Reading from php://input on a webserver will retrieve the Body of the ... HTTP Request. ... Is there any way to retrieve the POST message body when a form is ... PHP script has to be able to handle forms with file uploads. ...
    (php.general)
  • Re: How can I increase the shells (or specific applications) memory limit?
    ... assign more memory to a PHP script running in a shell and/or in a browser.. ... I'm building a PHP script that has to retrieve pretty large sets of data ... quickly runs out of memory. ... the script still bails out with a memory limit ...
    (freebsd-questions)
  • Retrieving the multiple values set by a 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 ... how do I iterate through all the values that form_variable has been ...
    (comp.lang.php)
  • How to get a Dynamic Javacript Form variables seperated in PHP
    ... additional fields (see javascript code bellow). ... I am trying to retrieve ... the values entered into these fields from my php script. ...
    (comp.lang.php)