网络编程 
首页 > 网络编程 > 浏览文章

php实现保存submit内容之后禁止刷新

(编辑:jimmy 日期: 2024/10/14 浏览:3 次 )
复制代码 代码如下:
$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="新規登録" name="insertN" class="box1a"></input>
<?php }else{?>
<input type="botton" value="新規登録" name="insertN" class="box1a" disabled></input>
<?php }?>
上一篇:PHP fopen()和 file_get_contents()应用与差异介绍
下一篇:php过滤所有恶意字符(批量过滤post,get敏感数据)