What tips do you have to prevent forms from being submitted repeatedly? Let’s talk about Iko Iko. !

  ios, question

What tips do you have to prevent forms from being submitted repeatedly? Let’s talk about Iko Iko. ! Be more specific, thank you

Disable submit button
Use Javascript to disable the submit button after the form is submitted. This method prevents impatient users from clicking the button many times. But there is a problem. If the client forbids Javascript, this method will not work.

Post/Redirect/Get mode
Page redirection is performed after submission, which is the so-called Post-Redirect-Get (PRG) mode. In short, when the user submits the form, you perform a client-side redirection and go to the submission success information page.

This can avoid repeated submission caused by users pressing F5, and it will not give rise to warnings of repeated submission of browser forms, and can also eliminate the same problems caused by pressing forward and backward of the browser.

Store a special flag in the session
When the form page is requested, a special character string is generated, stored in the session and placed in the hidden field inside of the form. When accepting processing form data, check whether the identification string exists, delete it from the session immediately, and then process the data normally.

If it is found that the form submission inside does not have a valid flag string, this means that the form has already been submitted and this submission is ignored.

This gives your web application more advanced XSRF protection.

Adding Constraints to Database inside
Add unique constraints to the database inside or create unique index to prevent duplicate data. This is the most effective way to prevent repeated submission of data.

The above information comes from open source China

In fact, I have said so much, that is disable ,token, Redirect, database identification