tags:

views:

44

answers:

3

Hello all

I'm currently developing a page where the user fills out a form, and when submitted they are taken to the next page. When on the next page, I want to have it so that if the user went back to the previous page using the back button, or hit refresh, the submission will not be saved into the DB.

Now I recall reading somewhere that if you had a way to make each submission unique, this issue is averted, but after screwing around for hours on end, for the life of me I cannot recall how this could be done (using PHP), so long story short has anyone ran into this, and if so, what was your solution?

+3  A: 

Use the Post/Redirect/Get pattern to avoid this problem. See also Redirect After Post.

RedFilter
+1  A: 

Another way is to generate an identifier using uniqid and include it in the form as a hidden input. On submission, store that identifier in a database column marked with a UNIQUE index. This will cause subsequent submissions to throw a SQL error, which your application can handle gracefully.

ceejayoz
A: 

You can add any confirmation on the second page.
By adding any confirmation box or any button.... by which you can confirm that whether user want to save it or not.... and if you don't want any confirmation...then you can delete the last record....by using managing session...but it is not good practice to fire the query very soon and delete in that kind..
so best way will be by adding any confirmation msg....

Nitz
I don't think you understood the question.
ceejayoz