Reputation: 11
If one has multiple input forms, is there a way for one to distinguish one submit button from the other? The reason is I have two forms and each form performs a different task.
Both forms do a submit and each submit will perform an SQL query. The first one is a SELECT FROM query to do a search for data and the second will do UPDATE or DELETE (using this code on two different pages) query.
Upvotes: 0
Views: 65
Reputation: 5094
There might be many cases
First: if all the forms have the same action attribute then you will have to name the submit buttons differently.
second: If the forms have different actions then there is no need to name the buttons differently. You can achieve the task with the same name.
Three: if you want some of the fileds to have a different form action in your form then you can try this
<form action="demo_form.asp">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="Submit"><br>
<input type="submit" formaction="demo_admin.asp"
value="Submit as admin">
</form>
To learn about form action overriding click here
Upvotes: 1
Reputation: 536
you specify the <input type="submit" name="form1" />
that name part is the way to specify seperately to php
Upvotes: 0
Reputation: 3981
Upvotes: 0