Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

same form data, different actions on two separate submit buttons

Tags:

javascript

php

I have what is essentially a shopping cart that needs to have two separate checkout options. The first of which takes the user away from the site, but form data must be posted.

How can I create two submit buttons that will send the same form data to their own separate page?

like image 904
mrpatg Avatar asked May 11 '26 14:05

mrpatg


2 Answers

If I understand correctly, you have 2 submit buttons on the same page and both of them have the same form if that is so, this should do the trick.

if(isset($_POST['name1'])) {
//do stuff
}

if(isset($_POST['name2'])) {
//do other stuff
}
like image 160
lemon Avatar answered May 14 '26 03:05

lemon


Well you could do this: -

define your form with action=""

then have two buttons: -

<input type="button" value="button1" onClick="this.form.action='your_first_action_url'; this.form.submit()">
<input type="button" value="button2" onClick="this.form.action='your_second_action_url';this.form.submit()">
like image 42
chefsmart Avatar answered May 14 '26 03:05

chefsmart