i have a php script and i give all data and save data stored on my mysql database.But after that if refresh the page the same data will again stored in database.How i can avoid this.Please help me.
Asked
Active
Viewed 1,186 times
1
-
3possible duplicate of [how to prevent form resubmission when page is refreshed via PHP](http://stackoverflow.com/questions/6320113/how-to-prevent-form-resubmission-when-page-is-refreshed-via-php) – Rikesh Mar 08 '13 at 06:11
-
After user submits, you have to navigate them away for the form page. – devBinnooh Mar 08 '13 at 06:12
-
With out your code It cant be predict as what is happening – Thirumalai murugan Mar 08 '13 at 06:18
2 Answers
1
Use header and redirect the page.
header("Location:your_page.php");
You can redirect to same page or different page.Unset $_POST after inserting it to Database.
unset($_POST);

Prasanth Bendra
- 31,145
- 9
- 53
- 73
0
It seems you are resending the form data on page refresh. If once you save the form data don't render the same form again to the view. You must prevent it by checking if data is saved. Also you can redirect the user from the form view if saving is success.

Harish Ambady
- 12,525
- 4
- 29
- 54