Hitting browser "Back" button causing details to save
I've had a report from a user that whenever the开发者_运维知识库y go to edit their profile details, if they hit "Back" on their browser, any changes they may have made are saved, when they should only be saved by them clicking the "Save" button in the page.
What possible reasons are there for this happening, and how can I prevent it?
Sound like a form resubmission issue. Have a look here and see if that points you in the right direction
This sort of thing can also happen if the user double-clicks on the 'submit' button and triggers two form submissions.
The solution to it is to have a field in the form which is a unique reference ID which is generated each time the form is loaded.
When the form is submitted, your program should make a note that this ID has been used (maybe store this in the user's session), and reject any subsequent attempts to post a form with the same ID.
There are many ways of implementing this, so I won't give you a code example, but it should be fairly straightforward.
Hope that helps.
精彩评论