stop resubmiting of post data when 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
hibbeac1
Forum Newbie
Posts: 13
Joined: Thu Oct 30, 2003 10:25 am

stop resubmiting of post data when refresh

Post by hibbeac1 »

I have an application that is in PHP and MySQL. When a button is pressed it will perform and action on the database either to add, edit or delete data that a user has entered. When adding data after the refresh button is pressed at the top of the page the data is added again, so you get another occurence of the data. Is there anyway of stopping this happening.
User avatar
aquila125
Forum Commoner
Posts: 96
Joined: Tue Dec 09, 2003 10:39 am
Location: Belgium

Post by aquila125 »

put a hidden field in the form with a random number in it.. add this number to the database, if it already exists (and the data is the same), don't save the data...

You could just check the data and skip the random number ofcourse.. (perhaps at some time you would want to add the same data twice..)
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post by Paddy »

Or redirect it to itself to get rid of the post data. Add

header("Location: thepage.php");

After the db manipulation and before any html.
Post Reply