Samuel Stiles Samuel Stiles - 1 year ago 61
HTML Question

HTML form with multiple "actions"

I'm setting up a form wherein I need two "actions" (two buttons):

1 - "Submit this form for approval"

2 - "Save this application for later"

How do I create an HTML form that supports multiple "actions"?


<form class="form-horizontal" action="submit_for_approval.php">

<form class="form-horizontal" action="save_for_later.php">

I need to combine these two options-for-submitting into one form.

I did some basic research but couldn't find a definitive answer as to whether or not this is possible, and/or any good resources to links for a workaround.

Thanks in advance.

Answer Source

As @AliK mentioned, this can be done easily by looking at the value of the submit buttons.

When you submit a form, unset variables will evaluate false. If you set both submit buttons to be part of the same form, you can just check and see which button has been set.


<form action="handle_user.php" method="POST" />
  <input type="submit" value="Save" name="save" />
  <input type="submit" value="Submit for Approval" name="approve" />


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


If you'd rather not change your PHP setup, try this:
This is the JavaScript method @AliK was reffering to.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download