1. Use JS to make the button disabled (disable) after one click. + = prevents multiple clicks from happening and is simpler to implement.
Disadvantage: If the client prohibits JavaScript scripting, it fails.
2. Perform page redirection (redirect) after successful submission. = = Go to the Submit Success Information page.
Features: Avoid F5 repeated submissions, eliminate browser forward and backward press the same problem caused.
3. The form hides the session in the hidden field (the token generated when the form is requested). = = after receiving the form data, check whether this flag value exists, first delete, and then process the data; If it does not exist, the description has been submitted, ignoring this submission.
/*|---------------------------------| Principles & Code Examples |@ Black-eyed poet <www.chenwei.ws>|--------------------------------- *///server generates a random number to the SESSION, assigned to the form page $data[' sess_id '] = $_session[' sid ') = Mt_rand (9999), $this->load->view (' form ', $data);//The form page hidden field holds this session value <input type= "hidden" name= "Sid" Value= "<?= $sess _id;?>" >//Handle if ($_post[' SID ' = ' = ' && $_post[' sid '] = = $_session[' sid ']) {unset ($_session[' Sid ')); Echo ' processes the data ';} else{Echo ' has submitted a form ';}
4. Database Unique index constraints (the most effective way to prevent duplicate data).
---------------------------------------------------------------------------------------------
[PHP] Several ways to prevent forms from repeating submissions