Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Handle multiple submit buttons on same form?

Status
Not open for further replies.

tonedef

Programmer
May 24, 1999
64
0
0
US
I have a form that has multiple submit buttons. The form action calls another .php3 page to process. I don't seem to be able to access the value of my submit buttons to conditionally process branches of code. I am able to do this in other environments. Am I doing something incorrect? Following are some snippets to get an idea.

[tt]
<HTML>
// calls form2 as form action
<BODY>
<FORM Action=&quot;form2.php3&quot; METHOD=&quot;POST&quot;>
<INPUT TYPE=SUBMIT NAME=&quot;SubmitType&quot; VALUE=&quot;A&quot;>
<INPUT TYPE=SUBMIT NAME=&quot;SubmitType&quot; VALUE=&quot;B&quot;>
<INPUT TYPE=SUBMIT NAME=&quot;SubmitType&quot; VALUE=&quot;C&quot;>
</FORM>
</BODY>
</HTML>

<HTML>
// process form1
...
<?
IF ($HTTP_POST_VARS[&quot;SubmitType&quot;] == &quot;A&quot;)
{
...
}
ELSEIF ($HTTP_POST_VARS[&quot;SubmitType&quot;] == &quot;B&quot;)
...
[/tt]

All of the conditions will evaluate to false!

Any thoughts,

tone
 
Try adding an
Code:
echo $SubmitType;
at the top of your process script to see exactly what is getting passed. That might help identify the problem.

-Rob
 
Why don't you give different names to the buttons?

I do that and i don't have anykind of trouble.

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin@ip.pt
 
Yep. I also use different names and works fine

Regards
Loganmex
 
What you do is give the buttons different names. Also, what I do is simply:

If($submit1) { code }
if($submit2) { code } etc.

This will give you a correct evaluation for each button.

Artificial Intelligence is no match for Natural Stupidity
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top