无法修改标头信息 - 已发送的标头

时间:2015-01-07 08:18:40

标签: php

我遇到了问题..

输出错误:无法修改标题信息..

原因是什么?我怎么能解决它.. 感谢您的帮助..我已经检查了所有,但是我仍然无法修复它。会出现什么问题?

以下是我的代码:

<!DOCTYPE html>
<html dir="ltr" lang="en-US"><head><!-- Created by Artisteer v4.3.0.60747 -->
    <meta charset="utf-8">
    <title>Home</title>
    <meta name="viewport" content="initial-scale = 1.0, maximum-scale = 1.0, user-scalable = no, width = device-width">

    <link rel="stylesheet" href="style.css" media="screen">
    <link rel="stylesheet" href="style.responsive.css" media="all">
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Salsa|PT+Sans&amp;subset=latin">

    <script src="jquery.js"></script>
    <script src="script.js"></script>
    <script src="script.responsive.js"></script>


<script>jQuery(function ($) {
    'use strict';
    if ($.fn.themeSlider) {
        $(".art-slidecontainera65d557e889141cb8638b82feda1c335").each(function () {
            var slideContainer = $(this), tmp;
            var inner = $(".art-slider-inner", slideContainer);
            inner.children().filter("script").remove();
            var helper = null;

            if ($.support.themeTransition) {
                helper = new BackgroundHelper();
                helper.init("fade", "next", $(".art-slide-item", inner).first().css($.support.themeTransition.prefix + "transition-duration"));
                inner.children().each(function () {
                    helper.processSlide($(this));
                });


            } else if (browser.ie && browser.version <= 8) {
                var slidesInfo = {
".art-slidea65d557e889141cb8638b82feda1c3350": {
    "bgimage" : "url('images/slidea65d557e889141cb8638b82feda1c3350.jpg')",
    "bgposition": "0 0",
    "images": "",
    "positions": ""
},
".art-slidea65d557e889141cb8638b82feda1c3351": {
    "bgimage" : "url('images/slidea65d557e889141cb8638b82feda1c3351.jpg')",
    "bgposition": "0 0",
    "images": "",
    "positions": ""
}
                };
                $.each(slidesInfo, function(selector, info) {
                    processElementMultiplyBg(slideContainer.find(selector), info);
                });
            }

            inner.children().eq(0).addClass("active");
            slideContainer.themeSlider({
                pause: 2600,
                speed: 600,
                repeat: true,
                animation: "fade",
                direction: "next",
                navigator: slideContainer.siblings(".art-slidenavigatora65d557e889141cb8638b82feda1c335"),
                helper: helper
            });


        });
    }
});
</script></head>
<body>
<div id="art-main">
<header class="art-header">

    <div class="art-shapes">

            </div>

<h1 class="art-headline">
    <a href="index.php">FPES</a>
</h1>
<h2 class="art-slogan">Faculty Performance Evaluation System.</h2>

<?php  
//connect to the database 
$connect = mysql_connect("localhost","root",""); 
mysql_select_db("db_fpes",$connect); //select the table

if(isset($_POST['btn_submit'])){
    $username = $_POST['username'];
    $password = $_POST['pass'];
    $result  = mysql_query ("SELECT * FROM professors where fac_stat = 1 and Faculty_code = '".$username."' and Faculty_code = '".$password."' ");
    if($username == 'admin' && $password == 'admin' && mysql_num_rows($result) == 0 ){
                header('Location: admin/home.php'); die;
    }
    else
    {
            $row = mysql_fetch_assoc($result);
            if($row['system_user'] == 1){
                header('Location: Grading/index.php'); die;
            }
            else if($row['system_user'] == 2){
                header('Location: Secretary/home.php'); die;
            }
            else
                header('Location: index.php');  die;
    }
}
?>
<nav class="art-nav">
    <ul class="art-hmenu"><li><a href="home.html" class="active">Home</a></li>
    <li><a href="add-profile.html">About Us</a></li>

</ul> 
</nav>
</header>
<div class="art-sheet clearfix">
            <div class="art-layout-wrapper">
                <div class="art-content-layout">
                    <div class="art-content-layout-row">
                        <div class="art-layout-cell art-content"><article class="art-post art-article">                           
                <div class="art-postcontent art-postcontent-0 clearfix"><div class="art-content-layout-wrapper layout-item-0">
<div class="art-content-layout layout-item-1">
    <div class="art-content-layout-row">
    <div class="art-layout-cell layout-item-2" style="width: 100%" >
        <p></p><div id="a65d557e889141cb8638b82feda1c335" style="position: relative; display: inline-block; z-index: 0; margin: 0px;  border-width: 0px;  " class="art-collage">
<div class="art-slider art-slidecontainera65d557e889141cb8638b82feda1c335" data-width="900" data-height="287">
    <div class="art-slider-inner">
<div class="art-slide-item art-slidea65d557e889141cb8638b82feda1c3350" >


</div>
<div class="art-slide-item art-slidea65d557e889141cb8638b82feda1c3351" >


</div>

    </div>
</div>
<div class="art-slidenavigator art-slidenavigatora65d557e889141cb8638b82feda1c335" data-left="1" data-top="1">
<a href="#" class="art-slidenavigatoritem"></a><a href="#" class="art-slidenavigatoritem"></a>
</div>



    </div>


        <p>
        </p><p>
        </p>
    </div>
    </div>
</div>
</div>
<div class="art-content-layout layout-item-1">
    <div class="art-content-layout-row">
    <div class="art-layout-cell layout-item-3" style="width: 67%" >
        <h2><span style="color: rgb(128, 0, 0); line-height: 51px; font-size: 40px;">Welcome&nbsp</span><span style="color: rgb(108, 127, 147); line-height: 31px; font-size: 28px;">to our site!</span></h2>
        <h3><img width="250" height="195" alt="" src="images/1037312_small500.jpg" style="float: left; margin-right: 15px;" class="">Performance Faculty Evalutaion System.&nbsp;</h3>
        <p>Insert Description Here!.<br></p>
    </div>

    <div class="art-layout-cell layout-item-4" style="width: 33%" >
    <form method = "post" action = "">
        <h1>Please Login<br></h1><p style="margin-top: 10px;"> Username: <input type="text" name = "username" >&nbsp;</p><p>
        <p> Password: <input type="text" name = "pass"></p><p style="text-align: right;">&nbsp;
        <input type = "submit" name = "btn_submit" class="art-button" value = "Login"/><br></p>
    </form>
    </div>
    </div>
</div>



</article></div>
                    </div>
                </div>
            </div>
    </div>
<footer class="art-footer">
  <div class="art-footer-inner">
<p>GoMiracles © 2014 - 2015. All Rights Reserved.<br></p>
  </div>
</footer>

</div>


</body></html>

1 个答案:

答案 0 :(得分:1)

Headers already sent是一个问题,您尝试使用header()重定向用户,或者当您尝试在浏览器已呈现内容时启动会话session_start()时(例如html,但可以)例如,也是一个PHP echo语句。

要解决此问题,请在发送标头之前检查您是否有任何echo()语句或原始HTML,并检查<?php前面是否有空格。

可以在此处找到帮助您解决此问题的更详细答案:https://stackoverflow.com/a/8028987/4274852

我怀疑您没有向我们提供您的所有代码,因为我目前无法找到您的任何具体问题。我希望上面的链接可以帮助您调试代码,如果没有:确保在PHP代码上面发布所有内容。

请注意:我发现您仍在使用mysql_query语句,这些语句已被弃用。请改用msqliPDO

修改

我看到你发布了你的代码,尝试替换页面顶部的所有PHP代码而不是中间代码,它应该可以工作。在当前代码中,您在PHP代码之前有原始HTML(在这种情况下为<h1><p>元素),这使得无法使用header()发送更多标头数据,因为所有标头在呈现页面之前已经发送过。

我编辑了你的代码来解决这个问题,希望你可以在这里找到它(而不是在这里发布,这会产生一个尴尬的长答案):

http://pastebin.com/0JfBdjU5