Pete
Pete

Reputation: 1

Second submit button on same form but to another script

I have a form on my website (name/address details) on which I want to put a second submit button. To expand a little, the form emails the user details to me and sends the user to Paypal to pay a fixed fee. I would like the second button to do the same except send the user to a Paypal subscribe form to pay the total over 12 payments. As I know very little about coding, I am hoping someone could give me an answer in fairly simple terms as most I have read on here baffle me somewhat.. lol (sorry folks:-)

Here is what I have on my form already -

<form name="form2" method="post" action="paypal.php" onSubmit="return validate()">
    FORM CONTENT
</form>

My button reads - <input type="submit" name="submit" value="pay now"> and I'm using my own button image <img src="imagery/paylogo.jpg border="0">.

I have copied and amended paypal.php with a paypal subscribe script but now need to know the code to make my second button go to that script.

Thanks to all in advance for any advice you can give me.

Upvotes: 0

Views: 67

Answers (2)

Pete
Pete

Reputation: 1


I now have a solution to this. A guy wrote a further script for me which is working okay. He added the script - paypalall.php which I have shown below. He also amended the form action to go to this script.

<script><?php
if ($_POST['submit'] == 'Full Payment - Click Here'){
include_once('paypal.php');
} else if ($_POST['submit'] == 'Monthly Payment - Click Here'){
include_once('paypal2.php');
} else {
//exception case! set as full pay
include_once('paypal.php');
} 

I hope others find it useful.
Thanks to all. Pete

Upvotes: 0

Michał Lipa
Michał Lipa

Reputation: 978

You can use select in your form.

<form name="form2" method="post" action="paypal.php" onSubmit="return validate()">
<select name="pay_option">
  <option value="pay1">Pay 1</option>
  <option value="pay2">Pay 2</option>
</select>
<input type="submit" name="submit" value="pay now">
</form>

and then in your paypal.php

if ($_POST["pay_option"] == "pay1"){

//code for your option 1

}elseif($_POST["pay_option"] == "pay2"){

//code for your option 2

}

Upvotes: 1

Related Questions