表單頁面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);