php防止post重复提交

表单页面php

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

 

 

php页面this

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);
相关文章
相关标签/搜索