1

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.

Qaz Kile
  • 9
  • 7

2 Answers2

1
  1. Use header and redirect the page.

    header("Location:your_page.php"); You can redirect to same page or different page.

  2. 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