SITERAW

Form with multiple actions

Author Message
Pepsida # Posted yesterday
An HTML form with more than one action Hi all,

I'm setting up a form wherein I need to have at least two different "actions", with two different submit buttons.

For example, I need both:
  • Submit the form now
  • Save the information for later
And depending on which one is clicked the user is then sent to a different page.
Here is what I want to do.
<form method="post" action="submit.php" action="save.php">
I need to "link" each action to one of the submit button and I don't know how to proceed.

Any tips on how I can do it ?

Thanks in advance !
Ads
Rel0ad # Posted two hours ago
Rel0ad You don't need two forms to do that.

If one of the buttons is clicked it will show up in backend, that's how you differentiate the two and redirect accordingly.
Posey # Posted one hour ago
Posey This can be done by changing the values of the submit buttons, but you will need a server side language to

In PHP:
if($_POST['send']) { ... }

if($_POST['save']) { ... }
You can read more about how to handle forms here : http://www.siteraw.com/html-css/how-to-create-a-website/forms.
Demonecromancy # Posted 37 minutes ago
Demonecromancy You can also fiddle with JS if you want to send the post data to another page entirely, not just redirect the user there.

If you don't need to, stick with the above answers and a back-end language.
Jaguar # Posted 5 minutes ago
Jaguar If you want a complete code.
<?php

if(isset($_POST["send"]))
header("Location: submit.php");

elseif(isset($_POST["save"]))
header("Location: save.php");

?>

<form method="post">
<input
type="submit" name="send" value="Send" />
<input
type="submit" name="save" value="Save" />
</form>

Post a reply