Tip 1. Use JS to make the button disabled once (disable ). It is easy to implement multiple clicks. Disadvantage: it is invalid if the client disables JavaScript scripts. 2. After the submission is successful
Tip 1. Use JS to make the button disabled once (disable ). = Prevent multiple clicks, which is easy to implement. Disadvantage: it is invalid if the client disables JavaScript scripts. 2. After the submission is successful
Bytes ---------------------------------------------------------------------------------------------------
1. Use JS to make the button disabled after one click (disable ). => To prevent multiple clicks, the implementation method is simple.
Disadvantage: it is invalid if the client disables JavaScript scripts.
2. After the submission is successful, execute page redirection (redirect ). => Go to the successful submission page.
Features: avoid repeated submission of F5 and eliminate the same problem caused by browser forward and backward pressing.
3. Store the session in the form hiding field (the mark generated when the form is requested ). => After receiving the form data, check whether the flag value exists. Delete the value first and process the data. If the value does not exist, it indicates that it has been submitted. Ignore this submission.
/* | ------------------------------- | Principle and sample code | @
| --------------------------------- * // The server generates a random number and saves it to the session, distribute to table single page $ data ['sess _ id'] = $ _ SESSION ['sid '] = mt_rand (1000,999 9 ); $ this-> load-> view ('form', $ data); // hide the field on a single table page to store this session Value
// Process if ($ _ POST ['sid ']! = ''& $ _ POST ['sid '] = $ _ SESSION ['sid']) {unset ($ _ SESSION ['sid ']); echo 'process data';} else {echo 'submitted form ';}
4. unique database index constraints (the most effective way to prevent duplicate data ).
Link: http://www.cnblogs.com/farwish/p/3911588.html
@ Blackeye poet