dsa88886666 2012-07-05 09:56
浏览 43
已采纳

PHP标头(位置)错误

Whenever i open the page i receive following errors:

[04-Jul-2012 17:10:45] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/test/public_html/admin/header.php:39) in /home/test/public_html/admin/edAgent.php on line 80

[04-Jul-2012 17:10:55] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/test/public_html/admin/header.php:39) in /home/test/public_html/admin/edAgent.php on line 80

Pieces of code including headers:

Encoding header:

header('Content-Type: text/html; charset=utf-8');

Login redirect header:

if(!isset($_SESSION["login"])OR $_SESSION["login"]!=1){        
    header('Location: login.php');
    exit;     
    }

Checks if logged user has privileges to edit:

if($level!='4') {
    header('Location: acd.php?msg=1');
    exit;
}

Checks if ID exists:

if ($nUsers==0) {    
    header('Location: acd.php?msg=2');
    exit;    
}

Checks if information is editable:

if($access != '4') {        
    header('Location: acd.php?msg=1');
    exit;        
}
  • 写回答

3条回答 默认 最新

  • doufei7516 2012-07-05 11:21
    关注

    If headers are already sent the JS method should work.

    print '<script type="text/javascript">window.top.location.href = "'. $myurl .'";</script>';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?