Prevent Insert on 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
shivam0101
Forum Contributor
Posts: 197
Joined: Sat Jun 09, 2007 12:09 am

Prevent Insert on Refresh

Post by shivam0101 »

Whenever i refresh a new row is inserted. How to prevent this?
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Post by Stryks »

Just out of interest, when you hit refresh, does your browser say something like, "The page you are trying to view contains POSTDATA ... etc etc etc."?

Or just reloads and writes a new row?

Also, it would help if we can see the row creation code from the start of the page in question. Well .. from the start to the row creation code.

Cheers
shivam0101
Forum Contributor
Posts: 197
Joined: Sat Jun 09, 2007 12:09 am

Post by shivam0101 »

The page cannot be refreshed without resending the data ----warning
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If you write your form with a one-time use only token that the server looks for, the server wouldn't accept a second submission without getting a new token.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Another option is to redirect using header() immediately after the form submission.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

POST to a different page that processes, REDIRECT back to the page, using GET to retrieve relevant data if necessary.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply