PHP prevents form duplicate submission instances by session judgment


PHP uses session judgment to prevent form duplicate submission instances. To prevent duplicate operations after the user submits the form, session judgment is used to determine whether it is the first submission or not, otherwise, let him return to the previous form page.

The current form page is_submit is set to 0

 $_SESSION['is_submit'] = 0;
     User name: 
     Close code: 

If the form is submitted, set the current’is_submit to 1, and if post.php is refreshed, else code will be executed.

 if (isset($_POST['submit'])) { 
     if ($_SESSION['is_submit'] == '0') { 
         $_SESSION['is_submit'] = '1'; 
         Echo "Code block, things to do, code... return"; 
     } else { 
         Echo "Please do not submit PHP + SESSION repeatedly to prevent form from submitting repeatedly"; 

This article is reproduced from: Please indicate the source!