The scoring software I am working on should submit and store date in a DB. However re- submitting an action is not allowed in this sport. So I want to disable the page back functionality to avoid re-submitting the same (or revised) data. Any php or javascript solution is welcome. I do realize the opinions posted that the page back function should not be disabled principally but in this case it would be very helpful however.
Asked
Active
Viewed 34 times
-5
-
1That's impossible. Find a less ugly way. – nicael Mar 31 '18 at 21:00
-
2Your problem isn't the back button itself...see this for ways around it https://stackoverflow.com/questions/3923904/preventing-form-resubmission – Ctznkane525 Mar 31 '18 at 21:03
-
Disabling the back button doesn’t prevent resubmitting. – Sebastian Simon Mar 31 '18 at 21:05
1 Answers
0
Use $_SESSION to avoid re-submitting: Set a session variable on submit and if it's set don't process a second submit.
However the user could remove browser cookies and re-submit. If your casuistic needs to prevent it too, store the submitting ip in the database.
PS: About refresh, use Post/Redirect/Get: https://en.wikipedia.org/wiki/Post/Redirect/Get

Javier S
- 379
- 3
- 13