I’ve got a form, which when submitted collects the data and writes the values of the fields within my database. The form uses a post request to a response page which then connects to the database and posts all the fields necessary to my db.
I’ve also got a radiobuttons called payment and one of the options is paypal. My goal is to end up posting the fields to the db but also post the form data below to my paypal account in one go
<form name="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="myemails" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="item_name" value="Digital Download" />
<input type="hidden" name="amount" value="9.99" />
<input type="hidden" name="return" value="http://myurl/form.htm" />
<input type="hidden" name="notify_url" value="http://myurl/example/ipn.php" />
<input type="image" src="btn_buynow_LG.gif" border="0" name="submit" alt="Paypal" />
</form>
I know I can use the following command below to do a redirect to another page which has a form
if($_REQUEST['payment']=="Paypal") { redirect to another page with the code above, but the user has to click on submit again}
However I would just like the user to click on submit once and the my db records the details and then automatically redirects them to paypal.
That’s pretty trivial, just do:
I’d recommend fogetting about
$_REQUESTand using ONLY$_GETand/or$_POSTwhere needed.