I have a PHP shopping basket on my site. The shopping basket contains a form with the list and values of the items.
It looks something like this:
<form action="https://www.sandbox.paypal.com/us/cgi-bin/webscr" method="post">
<input....etc etc etc>
<input....etc etc etc>
<input type="submit" name="add-to-basket" value="Buy Now">
</form>
When the user clicks on "Buy Now", I want to run some final checks [in a function] before the form is submitted to Paypal. If the final checks are passed then the user will be taken to Paypal. If any of the checks fail the user will be brought back to the basket with some error messages.
The bit I want help with is the call to the function with the checks.
When a user clicks the "Buy Now" button can I call a function within the same page before the post fires? Or should I post to another page that runs the checks and then automatically posts the original form data to Paypal. Not sure if automatically posting forms is even possible? (To clarify, I should say that the user needs to be taken with the post data to Paypal)