无法修改标题 - 在PHP之前没有空格或文本

时间:2013-11-19 03:55:41

标签: php

我的页面members.php加载非常好。然后我按下提交按钮并执行FORM1中的代码....数据库得到更新,但我得到这是错误消息:

警告:无法修改标题信息 - 已在第84行的/usr/www/users/members.php中发送的文件(在/usr/www/users/header.php:101处开始输出)

header.php代码

<?
    //checks cookies to make sure they are logged in 
    if(isset($_COOKIE["user"]))
    {
        $username = $_COOKIE["user"]; 
        $pass = $_COOKIE["password"];

        $sqlcheck = mysql_query(".....")or die(mysql_error()); 
        while($sqlinfo = mysql_fetch_array( $sqlcheck ))
        {
            //if the cookie has the wrong password, they are taken to the login page 
            if ($pass != $sqlinfo['password'])
            {
                $var = "HTML CODE1"; 
            }
            //otherwise they are shown the admin area    
            else
            {
                $var= "HTML CODE2"; 
            }
        }
    }
    else //if the cookie does not exist, they are taken to the login screen 
    {
        $var=  "HTML CODE3"; 
    }
?> 
<link href='http://fonts.googleapis.com/css?family=Kavoon' rel='stylesheet' type='text/css'>
<link href="style.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-1.7.2.js" type="text/javascript"></script>
<style type="text/css">
</style>
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="headerBar">
  <tr >

    <td>

    <?PHP echo $var; ?>   // THIS IS LINE 101

    </td>
  </tr>
</table>

此处是members.php的代码

<?
    include 'datalogin.php';
    include 'header.php';
    require_once "phpuploader/include_phpuploader.php";
    session_start();

//checks cookies to make sure they are logged in 
    if(isset($_COOKIE["user"])) {
    $username = $_COOKIE["user"]; 
    $pass = $_COOKIE["password"];
    $check = mysql_query("SELECT * FROM members WHERE email = '$username'")or die(mysql_error());
    $info = false;
        while ($info2 = mysql_fetch_array( $check ))
            {
            if(! $info)
                 { $info = $info2; }

            //if the cookie is present but has the wrong password, they are taken to the login page 
            if ($pass != $info['password']) 
            {
                header("Location: login.php"); 
                exit();
            }  
            else //if the cookie is present and doesn'T have the wrong password they are shown the admin area    
            { 
                include 'header.php';
            }
        }
}

else //if the cookie is present and doesn'T have the wrong password they are shown the login page    
            {
                header("Location: login.php"); 
                exit();
            }   


//This code runs if the form 1 has been submitted

    if (isset($_POST['submit1'])) 
    { 
        //This makes sure they did not leave any fields blank
        if (!$_POST['email'] || !$_POST['password']) 
        {
            die('Email or Password must not be empty');
        }

        // don't know why this is there ?   
        if (!get_magic_quotes_gpc()) 
        {
          $_POST['email'] = addslashes($_POST['email']);
        }

        // checks if the username is in use
        $usercheck = $_POST['email'];       
        $check = mysql_query("SELECT email FROM members WHERE email = ...... " ) or die(mysql_error());
        $check2 = mysql_num_rows($check);


        // now we insert it into the database
        $insert = "UPDATE members SET email = ..... ";
        $add_member = mysql_query($insert);     
        header('Location: members.php');   // THIS IS LINE 84
        exit();
    }   
?>
<style type="text/css">
<!--
body {
    background-color: #d2d2d2;
}
-->
</style>
<title>MY SETTINGS</title>
<link href="table_style.css" rel="stylesheet" type="text/css" />
<link href="style.css" rel="stylesheet" type="text/css" />
<body><table width="100%" border="0" cellspacing="0" cellpadding="0" id="headerBar2" align="center">
  <tr>
    <td><div id="txtheader2">MY SETTINGS</div></td>
  </tr>
</table>

1 个答案:

答案 0 :(得分:0)

您的headers.php文件似乎正在向浏览器发送输出(例如CSS链接,脚本等)。因此,PHP必须在此时发送HTTP头。

如果您需要修改标题,则需要在将任何输出发送到浏览器之前执行此操作。