Have you ever encountered the title of "repeated submission? It is not difficult to solve this title. Here is a simple method to avoid repeated submission of the same form. First, we can define a session variable to retain the submission serial number of a form.
Have you ever encountered the title of "repeated submission? It is not difficult to solve this title. Here is a simple method to avoid repeated submission of the same form.
First, we can define a session variable to retain the submission serial number of a form. Here I define it as "$ userLastAction ".
Then add a hidden variable in the form and set the value to $ userLastAction 1:
>
Finally, determine whether the form has been submitted before processing and submission:
If ($ lastAction> $ userLastAction and inputIsValid (...)){
$ UserLastAction; // add 1 to the serial number
// Process form data
}
Avoid multiple form submissions
Submitted By: Douglas E. Cook
Date: 07/26/00
Does your database suffer from 'Duplicate post' syndrome? The cure isn't too difficult. Here is a *** way to prevent users from submitting the same form multiple times.
First, declare a session variable to store a serial number for each form. I call mine '$ userLastAction. 'Then, in every form where duplicate submission is a problem, include a hidden field, and set the value to $ userLastAction 1:
>
Finally, verify that the form has not been previusly submitted before acting on the submission:
If ($ lastAction> $ userLastAction and inputIsValid (...)){
$ UserLastAction; // Increment serial number
// Act on form here
}
This is just a small trick to avoid repeated submission of a form. This may prevent water injection. In addition, users may submit the same form again if they do not know whether the submission is successful due to network status or other reasons.
The important principle of this technique is that it does not allow users to submit again after the rollback. that is to say, it does not allow users to submit again after the rollback. In addition, the water injection measures of Ctrl-C/Ctrl-V cannot be avoided. After all, whether it is useful or not depends on the interests of webmasters.