As @AliK mentioned, this can be done easily by looking at the meaning of the submit buttons.
When you submit the form, undefined variables will evaluate to false. If you set both submit buttons to the same form, you can simply check which button was installed.
HTML:
<form action = "handle_user.php" method = "POST" />
<input type = "submit" value = "Save" name = "save" />
<input type = "submit" value = "Submit for Approval" name = "approve" />
</form>
Php
if ($ _ POST ["save"]) {
// User hit the save button, handle accordingly
}
// You can do an else, but I prefer a separate statement
if ($ _ POST ["approve"]) {
// User hit the Submit for Approval button, handle accordingly
}
EDIT
If you do not want to change your PHP setting, try the following:
http://pastebin.com/j0GUF7MVThis is the JavaScript method that @AliK repeated.
on this topic:
- 2 submit buttons for actions with a different URL
- Submit the form to another page (which is different from the page used in ACTION)
isaacparrot May 21 '13 at 2:12 a.m. 2013-05-21 02:12
source share