I was wondering does anyone here have an elegant and 100% fail safe solution for STOPPING
duplicate INSERT into the Database due to Back_button or Reload on browser being clicked
by the user.
FYI, I have implanted a few solutions via setting a SESSION to be ON after an INSERT is
made and then turned OFF after we arrived at that page through a certain path, but it does
not seem to be 100% fail safe and certainly not elegant.
So I was wondering if there is an elegant and Universal solution to this vexing issue?
You can have it redirect to the existing page, instead of a new page, that will also prevent the back button or the refresh button from re-posting the data. The point is, you need to use the header(‘Location: yourpagehere’); command to prevent the duplicating of data.
Any attempt to add the same data to the database should simply fail as a duplicate insert request anyway - as long as you are not using an autoincrement key. Since autoincrement keys are seldom required the problem of duplicated inserts should be fairly rare anyway.