首页 > 代码库 > php防止post重复提交

php防止post重复提交

表单页面

<?php $_SESSION[‘code‘]=mt_rand(1,1000);?>
<input type="hidden" name="scode" value="<?php echo $_SESSION[‘code‘]?>" />

 

 

php页面

if($_SESSION[‘code‘]!=$_POST[‘scode‘]){
            header(‘Cache-Control:no-cache,must-revalidat‘);
            header(‘Pragma:no-cache‘);
            $this->assign(‘num‘,4);
            $this->display("PetCate/AddNewPetCate");
            exit;
        }
        $_SESSION[‘code‘]=mt_rand(1,1000);

 

php防止post重复提交