PHP uses session judgment to prevent the form from being submitted repeatedly. When the user submits the form, in order to prevent repeated operations, the session is used to judge whether it is the first submission, otherwise it will return to the previous form page.
The current form page is_submit is set to 0 (Recommended learning: PHP video tutorial)
SESSION_START(); $_SESSION['is_submit'] = 0; <form id="reg" action="post.php" method="post"> <p>用户名:<input type="text" class="input" name="username" id="user"></p> <p>密 码:<input type="password" class="input" name="password" id="pass"></p> <p>E-mail:<input type="text" class="input" name="email" id="email"></p> <p><input type="submit" name="submit" class="btn" value="提交注册"/></p> </form>
It is time to submit the form. Set the current 'is_submit to 1. If post.php is refreshed, the else code will be executed.
SESSION_START(); if (isset($_POST['submit'])) { if ($_SESSION['is_submit'] == '0') { $_SESSION['is_submit'] = '1'; echo "代码块,要做的事,代码...<a onclick='history.go(-1);' href='javascript:void(0)'>返回</a>"; } else { echo "请不用重复提交<a href='index.php'>PHP+SESSION防止表单重复提交</a>"; } }
The above is the detailed content of How does the php interface determine repeated submissions?. For more information, please follow other related articles on the PHP Chinese website!