在删除记录时,我使用一种简单的方法来获得确认框,这里的问题是我无法找到删除后将header
代码重定向到其他页面的位置。我已经将它放在执行查询之后,并得到了这个错误。
无法修改标题信息-已由(输出开始于.
而且我没有重定向到所需的页面,但是不知怎么的,在重新加载页面记录时,它被删除了。
if(isset($_POST['submit'])){
$que=$db->prepare("DELETE FROM blogs WHERE blogs_id = :blogId");
$que->execute(array(':blogId'=>$blogId));
header("location:front.php");
}
<form method="POST">
<input type="submit" name="submit" value="Delete" onclick="return confirm("Are you sure you want to delete this?")" />
</form>
发布于 2015-10-31 05:48:47
替换
header("front.php");
使用
echo "<script> window.location='front.php';</script>";
发布于 2015-10-31 05:48:57
使用元刷新标记而不是标题重定向页面。
<meta http-equiv="refresh" content="0;url=http://example.com">
发布于 2015-10-31 05:52:11
您需要使用header("location:front.php");
而不是header("front.php");
//,但是在页眉之前不应该有任何回显或打印,否则它不会重定向。
要确认的输入是错误的,请将其更改为:
<input type="submit" name="submit" value="Delete" onclick='return confirm("Are you sure you want to delete this?")' />
https://stackoverflow.com/questions/33452197
复制相似问题