Page 1 of 1

find name of form

Posted: Wed Dec 14, 2005 2:49 pm
by bimo
I was wondering if the name of a submitted form is kept in GET or POST or REQUEST. If not, is there any way other than javascript to do find out which form was submitted without checking the form's structure against some kind of pattern.

Thanks,

h

Posted: Wed Dec 14, 2005 3:12 pm
by shiznatix
you could do

Code: Select all

<form name="coolba" action="script.php?f=coolba" method="post">
then just get the form name from $_GET['f']

if you put that on all your forms you will be supra solid

edit: alternativly you could do a input type=hidden kinda deal with the form name in each form, which might be quite a bit better

Posted: Mon Dec 19, 2005 9:45 pm
by bimo
Rigght, I was wondering where the form name is in the POST array. Is it something like $_POST['name'] or does it have a different key?

Posted: Mon Dec 19, 2005 10:01 pm
by Burrito
the form name is NOT passed with the posted data. you could do what shiznatix suggested (either suggestoin would work), or you could name your submit buttons and use some kind of conditional statement to determine which from was posted by determining which button was clicked.

Posted: Mon Dec 19, 2005 10:33 pm
by AKA Panama Jack
You would be better off using a hidden input tag for that.

Code: Select all

<input type="hidden" name="form_name_check" value="my form name">
You can change the value to a php variable so it can be changed. Then just check $_POST['form_name_check'] to see what form it was.

Another way would be to do something like this...

Posted: Tue Dec 20, 2005 12:26 am
by bimo
Thanks...