php實現保存submit內容之后禁止刷新
更新時間:2014年03月19日 16:03:16 作者:
這篇文章主要介紹了php保存submit內容之后禁止刷新的具體實現,需要的朋友可以參考下
復制代碼 代碼如下:
$strsql = "INSERT INTO `xxx` (`aaa`) VALUES ('".$_POST["bbb"]."','".$_POST["ccc"]."',,now())";
$result=@mysql_query($strsql,$my_con);
$maxrow=@mysql_affected_rows();
Testecho ($y.mysql_affected_rows()." $errcode ".$strsql); #debug
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
if($maxrow>0){
$insertflag =1;
}
echo '<script>location.href="6612.php?inserted=1"</script>';
重點是最后一句,在insert完之后,重新載入一次頁面,并且加上參數,然后在頁面上寫個判斷,又GET的參數并且為1的時候disabled。
復制代碼 代碼如下:
<?php echo $insertflag;print_r($_GET); if($_GET[inserted]!=1){?>
<input type="submit" value="新規(guī)登録" name="insertN" class="box1a"></input>
<?php }else{?>
<input type="botton" value="新規(guī)登録" name="insertN" class="box1a" disabled></input>
<?php }?>
相關文章
PHP表單驗證的3個函數ISSET()、empty()、is_numeric()的使用方法
PHP表單驗證的3個函數ISSET()、empty()、is_numeric()的使用方法分享,學習php的朋友可以參考下。2011-08-08