简体   繁体   English

无法修改输出已发送的标题信息标题

[英]Cannot modify header information headers already sent by output

Delete image than redirect the page with query string i add query string with header but its not working Header not working 删除图片而不是使用查询字符串重定向页面我添加了带有标题的查询字符串,但是它不起作用标题不起作用

Error 错误

headers already sent by output started at sidebar.php in delete.php 已由输出发送的标头从delete.php中的sidebar.php开始

Delete.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.'&section='.$section);
  exit();
}
 }
} ?>

index page check if page exist than load the page sidebar included in index page index.php 索引页面检查页面是否存在,而不是加载索引页面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>

You are getting this error because you are already outputting content before setting a header. 之所以出现此错误,是因为在设置标题之前已经输出了内容。

If your include("delete.php"); 如果您的include("delete.php"); is going to redirect then you will need to perform this before outputting content. 要重定向,那么您需要在输出内容之前执行此操作。

try... 尝试...

// 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PHP - 无法修改标头信息 - 标头已由(输出开始于 - PHP - cannot modify header information - headers already sent by (output started at 无法修改标题信息-标题已发送 - Cannot modify Header Information - headers already sent 无法修改标头信息 - 标头已发送 - Cannot modify header information - headers already sent 无法修改标头信息-标头已由发送 - Cannot modify header information - headers already sent by 无法修改已发送的标头信息标头 - Cannot Modify Header Information Headers Already Sent 为什么收到警告:无法修改标头信息-标头已经发送过(输出从...开始)? - Why am I getting Warning: Cannot modify header information - headers already sent by (output started at …)? 在CSV下载期间-警告:无法修改标头信息-已发送的标头(输出始于 - During CSV downloading - Warning: Cannot modify header information - headers already sent by (output started at PHP 重现警告“无法修改 header 信息 - 标头已由(输出开始于...”与 XAMPP 8..1.1 - PHP reproduce warning "Cannot modify header information - headers already sent by (output started at... " with XAMPP 8..1.1 PHP 5.4无法修改标题信息-标题已发送 - Php 5.4 Cannot modify header information - headers already sent 警告:无法修改标题信息 - 标题已在 wordpress 中发送 - Warning: Cannot modify header information - headers already sent by in wordpress
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM