Page 1 of 1

loop through all form elements

Posted: Tue Nov 11, 2003 8:06 am
by yaron
Hello all,
I have a form with an unknown number of text fields in it.
once submited i need my php script to get all those variables i.e. the text input names from the form.

is that possible or I have to specify each name one by one...?

Thanks

Posted: Tue Nov 11, 2003 8:09 am
by twigletmac
If you're using the $_POST array it's easy to deal with varying numbers of fields, for example:

Code: Select all

foreach ($_POST as $key => $value) {
    echo 'Field name: <b>'.$key.'</b> and value: <b>'.$value.'</b><br />';
}
Mac

Posted: Tue Nov 11, 2003 8:19 am
by yaron
Hey,
Thanks... got it myself and just wanted to write the answer but you beat me to it.

Thanks a lot...

Posted: Tue Nov 11, 2003 8:21 am
by Nay
Don't you know, she's the fastest typer ;)

-Nay