Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid Page Reload Resend-Data message with PHP

Tags:

php

I am relatively new to PHP, so my apologies if the answer is trivial. Lol

I wrote a simple Contact Us email form (actually a WordPress page-template file). All the code is in one file.

After the user submits the form and the email is sent, the file generates a Thank You message.

If the user reloads the Thank You page, they are prompted to "Resend the Form Data," which is why I am asking this question.

My question: How do I avoid the prompt to resend the form data and still keep all of my code (including the Thank You data) in one file?

EDIT: I've seen folks use headers( Location: ), but I don't think that will work for if I want to keep all my code in one file.

like image 839
Jeff Avatar asked Dec 05 '25 17:12

Jeff


1 Answers

You could redirect to a different query.

header("Location: ?page=thankyou");

Then, you don't even need to check if the POST data was sent. Just display the thank you page if page is equal to thank you.

like image 105
Tyler Carter Avatar answered Dec 10 '25 01:12

Tyler Carter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!