当前表单页面is_submit设为0
- 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>
若是提交表单了,设当前'is_submit为1,若是刷新post.php,那么将执行else代码
- SESSION_START();
- if (isset($_POST['submit'])) {
- if ($_SESSION['is_submit'] == '0') {
- $_SESSION['is_submit'] = '1';
- echo "代码块,要做的事,代码...";
- } else {
- echo "请不用重复提交";
- }
- }
本文转自:https://www.sucaihuo.com/php/437.html 转载请注明出处!