One form, one button, two actions?

2019-09-13 20:01发布

问题:

I have a page orderbelow.php which has a form on it with one button "Order Now".

The form is submitted to send-order.php which sends an email to the website owner. The script on send-order.php also directs the user to a new page completeyourorder.php.

There is a form on completeyourorder.php with a button that has the action of sending the user to paypal to complete the payment.

Is it possible to have one button on the first form orderbelow.php that sends the email to the owner, and sends the user to paypal?

This will remove one step in the current process.

Thanks

回答1:

You can either send a email to the owner without refreshing the page: this should be done with AJAX (fancy name for simple Javascript requests sending ^^).

You can also add a location header in your first PHP script to automatically redirect to the second PHP script: this should be done with the function header in PHP.



标签: php forms action