Hello All,
I am performing some action (insertion, deletion, etc). Each time i refresh the page, i get a pop-up message asking whether to post data or not.
What can i do to prevent this?
Are there any functions in PHP or MySQL to prevent this?
Thanks and Regards,
Dream2rule
To prevent reposting of data by the user in the front-end
Moderator: General Moderators
-
dream2rule
- Forum Contributor
- Posts: 109
- Joined: Wed Jun 13, 2007 5:07 am
To prevent reposting of data by the user in the front-end
Last edited by dream2rule on Thu Aug 02, 2007 5:50 am, edited 1 time in total.
-
dream2rule
- Forum Contributor
- Posts: 109
- Joined: Wed Jun 13, 2007 5:07 am
You can't stop the user from posting the same data over and over again.. (At best you can hope that the user-agent accepts headers to set the cache validity to sometime in the past)
What you could do is add a version number fo the post data... This way, you can verify is the data is still up to date, and accept the posted data... Or reject it... (I usually do this by adding a form + number in the user's session.. And each time i process a form, i verify if the number still exists... )
What you could do is add a version number fo the post data... This way, you can verify is the data is still up to date, and accept the posted data... Or reject it... (I usually do this by adding a form + number in the user's session.. And each time i process a form, i verify if the number still exists... )
I normally use a header redirect to take the user back to the form or index page after processing all the data. This eliminates the refresh-insert problem, also the back button will still ask a user if they want to re-post their data.
put this after you have done everything on your insert page
obviously replacing finished-page.php with one of your choice.
put this after you have done everything on your insert page
Code: Select all
header("location: finished-page.php");
exit();- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
If you post to the same page, upon successful processing of the posted variables, you can simply redirect to the same page. Posted data is actually a PART OF the page being posted to, so if you redirect to the same URL, they will still be on the same physical page, but minus the posted variables. And header redirection "replaces" the current page request, so there's no worries with the back button.phpdevuk wrote:I normally use a header redirect to take the user back to the form or index page after processing all the data. This eliminates the refresh-insert problem, also the back button will still ask a user if they want to re-post their data.
Code: Select all
header('Location: ' . $_SERVER['REQUEST_URI']);