php實現(xiàn)保存submit內容之后禁止刷新

字號:


    這篇文章主要介紹了php保存submit內容之后禁止刷新的具體實現(xiàn),需要的朋友可以參考下
    代碼如下:
    $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完之后,重新載入一次頁面,并且加上參數(shù),然后在頁面上寫個判斷,又GET的參數(shù)并且為1的時候disabled。
    代碼如下:
    <?php echo $insertflag;print_r($_GET); if($_GET[inserted]!=1){?>
    <input type="submit" value="新規(guī)登録" name="insertN"></input>
    <?php }else{?>
    <input type="botton" value="新規(guī)登録" name="insertN" disabled></input>
    <?php }?>