tags:

views:

180

answers:

4

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?

+5  A: 

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($_SUBMIT['name1']) { //do stuff }

if(isset($_SUBMIT['name2']) { //do other stuff }
lemon
A: 

When you press the submit_1 button will send it to the process_1.php form.

There is no way the user will be able to press the second button.

What you need is one script that once it receives the information of the form. It forwards it to the two scripts that you want.

elviejo
+2  A: 

you could set an onclick handler to the buttons and change the form action dinamically.
I'm giving this answer because you have the javascript tag and i assume the external site receives the parameters via POST METHOD so you could not make a redirection in php

But i wouldn't trust in this because it require the users having javascript enabled...

Cesar
A: 

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()">
chefsmart