php防止页面刷新重复提交数据
- <?php
- session_start();
- if($_POST){
- $data = $_POST[name];
- $tag = $_POST[tag];
- if($_SESSION[status]==$tag){
- echo $data;
- }
- else{
- echo "不允许刷新!";
- }
- }
- $v = mt_rand(1,10000);
- ?>
- <form method="post" name="magic" action="">
- <input type="hidden" name="tag" value="<?php echo $v;?>" />
- <input type="text" name="name" />
- <input type="submit" value="submit" />
- </form>
- <?php
- $_SESSION[status] = $v;
- ?>
本文转自许琴 51CTO博客,原文链接:http://blog.51cto.com/xuqin/1183398
,如需转载请自行联系原作者