删除图像比使用查询字符串重定向页面我添加带标题的查询字符串但不起作用 标头不工作
错误
输出发送的标题已从delete.php
中的sidebar.php开始Delete.php
if(!isset($_SESSION['admin_email'])){
echo "<script>window.open('login.php','_self')</script>";
}
else {
if(isset($_GET['delete'])){
$id = $_GET['delete'];
$page = $_GET['page'];
$image = $_GET['image'];
$section = $_GET['section'];
$delete_p_cat = "delete from $page where id='$id' AND section = '$section'";
$run_delete = mysqli_query($con,$delete_p_cat);
if($run_delete)
{
header('Location: index.php?view&page='.$page.'§ion='.$section);
exit();
}
}
} ?>
索引页检查是否存在页面而不是加载索引页面中包含的页面侧栏 的的index.php
<div id="wrapper">
<?php include("includes/sidebar.php"); ?>
<div id="page-wrapper">
<div class="container-fluid">
<?php
if(isset($_GET['dashboard'])){
include("dashboard.php");
}
if(isset($_GET['view'])){
include("view.php");
}
if(isset($_GET['delete'])){
include("delete.php");
}
</div>
</div>
</div>
答案 0 :(得分:1)
您收到此错误是因为您在设置标题之前已经在输出内容。
如果您的include("delete.php");
要重定向,则需要在输出内容之前执行此操作。
尝试...
// before any output
if(!isset($_SESSION['admin_email']) && isset($_GET['delete'])){
include("delete.php");
}
?>
<div id="wrapper">
<?php include("includes/sidebar.php"); ?>
<div id="page-wrapper">
<div class="container-fluid">
<?php
if(isset($_GET['dashboard'])){
include("dashboard.php");
}
if(isset($_GET['view'])){
include("view.php");
}
if(isset($_GET['delete'])){
// remove this from delete.php
if(!isset($_SESSION['admin_email'])){
// looking at it, this may also want to be at the top
// if you are checking for a 'logged in user'
echo "<script>window.open('login.php','_self')</script>";
}
}
</div>
</div>