| |
关于变量撤消的问题

if(!empty($_POST["submit"]))
{
$articleid = $_POST["articleid"];
$comment = $_POST["comment"];
$author = $_POST["author"];
$ip = $_SERVER["REMOTE_ADDR"];
$datetime = date("Y-m-d H:i:s");


$sql = "insert into `comment` set articleid = $articleid, `comment` = '$comment', author = '$author', ip = '$ip', `datetime` = '$datetime'";
$rs = mysql_query($sql);
unset($_POST["submit"]);
if(!$rs){ echo "<script language='javascript'>alert('评论发表失败');history.go(-1);</script>";}
else { echo "<script language='javascript'>alert('评论发表成功');</script>";}
}

请问为什么发表评论之后,刷新还会自动发表空评论,
该怎么解决,谢谢
[推荐阅读] 吹牛贴
--------------------------------------------------------------------------------
你的unset之后,然后history了一下,就是又重新产生了一个submit,所以会继续
这里尽量不要用histroy,会造成多次的重复提交。

by admin | 来自 本站原创 | 不指定 2007-10-22 13:47 | 分类: PHP | 评论(0) | 引用(6) | 阅读(622)
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]