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);
相關文章
相關標籤/搜索