PHP
$thisfile=$_SERVER["REQUEST_URI"];
if(isset($_POST['comment'])&&!empty($_POST['comment'])){
if($id!=0){
$comment=$_POST['comment'];
if ($comment_query=mysql_query("INSERT INTO `photosite`.`comments` VALUES ('$id', '', '$firstname', '$surname', '$photo_id', '$comment', '$time')")){
header('Location: photopage.php?photo_id='.$photo_id.'', true, 303);
exit;
}else {
echo 'Could not add comment';
}
}else {
echo'Please Log In to add a Comment';
}
}
我不明白为什么我的
header('Location: photopage.php?photo_id='.$photo_id.'', true, 303);
exit;
还在等待用户重新提交数据吗?这链接到同一页面,因为它用于添加评论,因此当用户添加评论时,页面会刷新到同一页面。但是如果再次刷新,内容会重新提交,知道为什么吗?
更新:在同一个文档中的所有这些代码之前,我确实有一些东西回显。那是问题吗?
好的,我将表单操作更改为要处理的另一个页面。有以前的东西输出到页面,这是问题!