【问题标题】:Cannot modify header information - headers already sent (Confused) [duplicate]无法修改标头信息 - 标头已发送(混淆)[重复]
【发布时间】:2014-12-24 22:09:12
【问题描述】:

我正在制作一个脚本,它将与 phpVMS 的登录系统集成。

我已经让它工作了,如果有人进入登录页面,它就会显示。我怎样才能使它在有人打开网页但未登录时将其发送到登录页面?

目前,我收到错误:

无法修改标头信息 - 标头已由 /home/a4366948/public_html/mindfulhacker/private/man/index 中的(输出开始于 /home/a4366948/public_html/mindfulhacker/private/man/index.html:11)发送.html 第 16 行

我看到另一篇关于同样问题的帖子,但我对如何让样式表同时工作感到困惑 - 只有一个未格式化的页面是没有意义的!

    <html xmlns="http://www.w3.org/1999/xhtml"><head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <meta http-equiv="Content-Language" content="en-gb">
<meta name="language" content="eng">
<meta name="resource-type" content="document">
        <link rel="stylesheet" href="style.css" type="text/css">        
                    <title>Management System || CCVG</title>
<?php include('/home/a4366948/public_html/core/codon.config.php'); ?>
                                        </head>
                    <body>
                        <div class="container">
                            <div class="pagetitle">CapitalConnect Virtual Group - Management System</div>
                            <?php
                                if(Auth::LoggedIn()) {
                            ?>
                            <div class="menu"><table class="tb_blue_full margin_10" align="center" border="0" cellpadding="0" cellspacing="0" width="780"><tbody><tr><td class="cell_blue_botright" height="25" width="260"><div align="center"><strong><a href="/home/login_sso.php">Away Status</a></strong></div></td><td class="cell_blue_botright"  height="25" width="260"><div align="center"><strong><a href="/home/status.php">Students</a></strong></div></td><td class="cell_blue_bot" height="25" width="260"><div align="center"><strong><a href="/bookings/calendar.php">Classes</a></strong></div></td></tr></tbody></table></div>
                           <?php
} else {

header("Location: ".url('/login'));
exit;

}
?>
        <div style="clear: both;">&nbsp;</div>
</div>
</body></html>

【问题讨论】:

    标签: php css header


    【解决方案1】:

    在您拨打header 之前,您有一些内容。那是被禁止的。您必须将其移至顶部,例如:

    <?php
        if(!Auth::LoggedIn()) {
            header("Location: " . url("/login"));
            die();
        }
    ?>
    <html>
    <!-- … -->
    

    【讨论】:

    • 天啊!谢谢,我没想到会那么容易。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-09
    • 2012-06-19
    • 1970-01-01
    • 2011-01-15
    • 2012-10-10
    相关资源
    最近更新 更多