i have a php page with a form named "BuyForm" and a separate submit button.. like this
<form id="BuyForm" name="BuyForm" method="post" action="purchase.php" enctype="multipart/form-data">
// form goes here
<input type="submit" name="submit" value="Buy Now" class="buyButton">
</form>
now when i want to add a paypal button it gave me seperate form code like this Paypal button code
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="SOMEVALUE">
<input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal — The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
I m redirecting this form action="purchase.php" to this page only because all validation is in this page only, so what is in my mind is that on checking my form "BuyForm" for any errors and on successful i want it to redirect to another page where there is this paypal form.. Am I thinking right?
user have to click twice, once on submit button then it redirfects to paypal form where he'll click again on purchase button to make his purchase.. or what else can be done??
It's not the right way to do this. You should redirect the user from purchase page instead of letting user click twice. On purchase page, where you are redirecting user to paypal form, write this code and directly redirect user to paypal from there by this :
$paypal_email = "dummy@gmail.com";
$url='https://www.paypal.com/webscr?cmd=_xclick';
$currency="USD";
$paypal_redirect .= $url;
$paypal_redirect .= '&amount='.$cost;
$item_name = 'Item name';
$notify_url = "http://example.com/notify.php";
$cancel_url = "http://example.com/cancel.php";
$paypal_redirect .= '&return = http://example.com/thanks.php&paymentaction=authorization&business='.$paypal_email.'&item_name='.$item_name.'&no_shipping=1&no_note=1¤cy_code='.$currency.'&charset=UTF-8¬ify_url='.urlencode($notify_url).'&cancel_url='.urlencode($cancel_url).'&rm=2';
header("Location:".$paypal_redirect);
This is the right way to do this.