By pressing f5 after pressing the submit button

I have a PHP application where users can apply for a bonus. But before the bonus redemption code is launched, there is a confirmation page. The problem is that in IE , if you press f5 immediately after clicking the "Continue" button, the confirmation page will be updated while the bonus return code has already been activated by the "Continue" button and actually passes. But since the user still sees the confirmation page, they click the "Continue" button again, and now they get an error, because they are already registered.

Is there a way to disable the f5 button using javascript ? Is this the best way to do this? I tried many scripts that I found on the Internet to do this, but none of them achieve this. Is there a better way I can do this? Perhaps from the application side?

+4
source share
2 answers

Edit: if the result of applying for a bonus is a database, you can download existing applications on the confirmation screen and verify that it already exists.


Edit: another neat trick you can do is serailize / json_encode $ _POST and create a hash from that, save it in a database or user session and test it.


I would generate and add to the database one use token (hash) for the form as a hidden field, if the post-data is re-deleted, the token would already be used, and you can cancel the request for sending.

+1
source

There are several ways to solve your problem:

Checkout here: http://bjw.co.nz/developer/general/75-how-to-prevent-form-resubmission

I am using the second method (using sessions) and it really works well.

0
source

Source: https://habr.com/ru/post/1440439/


All Articles