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!

Recommended Today

Using PHP to develop HR system (5)

    This section describes how to split pages and usejqueryandajaxLocal refresh。 ================================================================================================== From our page, the menu on the left is unchanged, and the content area on the right changes according to different menus, so we wonder whether we can only focus on For local refresh on the right, you can use ajaxTechnology to […]