I have a store which works like this:
- The user adds stuff to his cart on the 1st page
- The user submits the cart (POST), all post data is stored in the session.
- The user fills out the form on the 2nd page, clicks submit again (second POST)
- The user comes at the “thank you” page (3rd), which takes all the session data, and the form POSTs the data and mails it.
The problem is, a simple refresh causes an empty table to be sent per email. How can I prevent this? Can I redirect somehow after the execution of the mail function? So the thank you page doesn’t do anything on refresh?
You can do by calling the PHP
header()function like this:The user will be redirected to the thankyou page and a reload there will not execute your code again.