Not allow POSTDATA to be sent on browser refresh

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
seodevhead
Forum Regular
Posts: 705
Joined: Sat Oct 08, 2005 8:18 pm
Location: Windermere, FL

Not allow POSTDATA to be sent on browser refresh

Post by seodevhead »

I have a php file that has a form that submits input through the POST method to itself. Once the page is reloaded after the form is submitted... users on this particular page are often hitting refresh in their browsers for various reasons, which will ask them if they want to resubmit the POSTDATA. Is there some code that I can put in my php file that will tell the browsers that even if the user hits refresh on the browser, not to ask or even think about the form that was just submitted? Thanks!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

same scenario found here in the last day.,. :roll:
duk
Forum Contributor
Posts: 199
Joined: Wed May 19, 2004 8:45 am
Location: London

Post by duk »

yeah but my post was not for that problem...

what you need to do is using a 3rd page to prevent that...

and if yu have duplicate entrys becouse the refresh is sending again the same DATA and the script is inserting data into the DB, i say check first if there is first the same name in the DB, in case yes, the script send ERROR message saying the email or name is already registered, and dont insert the DATA into DB...
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

Much like the other thread, the solution is to break that one page into three, each doing a seperate task:

Post-Redirect-Get pattern.

Fixes the problem nicely.
Post Reply