警告:无法修改标头信息(PHP 登录错误)


Warning: Cannot modify header information (PHP LOGIN ERROR)

可能的重复项:
PHP 已发送的标头

我正在尝试设置一个简单的php用户名和密码登录。在我尝试重定向到login_success.php页面之前,一切都正常工作。所有信息如下,请帮助。

############### Code 
Warning: Cannot modify header information - headers already sent by (output started at              
.../edits/admon/minastotian/checklogin.php:4) in    
.../edits/admon/minastotian/checklogin.php on line 15

这是检查登录.php页面。它打印出上面的错误,请帮助。提前谢谢你。

############### Code
<?php
    $host="i'm not telling"; // Host name 
    $username="db_user"; // Mysql username 
    $password="db_password"; // Mysql password 
    $db_name="db_name"; // Database name 
    $tbl_name="users"; // Table name
    // Connect to server and select databse.
    mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
    mysql_select_db("$db_name")or die("cannot select DB");

    // username and password sent from form 
    $myusername=$_POST['myusername']; 
    $mypassword=$_POST['mypassword']; 
    // To protect MySQL injection (more detail about MySQL injection)
    $myusername = stripslashes($myusername);
    $mypassword = stripslashes($mypassword);
    $myusername = mysql_real_escape_string($myusername);
    $mypassword = mysql_real_escape_string($mypassword);
    $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and     password='$mypassword'";
    $result=mysql_query($sql);
    // Mysql_num_row is counting table row
    $count=mysql_num_rows($result);
    // If result matched $myusername and $mypassword, table row must be 1 row
    if($count==1){
        // Register $myusername, $mypassword and redirect to file "login_success.php"
        $_SESSION['myusername'] = 'myusername';
        $_SESSION['mypassword'] = 'mypassword';
        header("location:login_success.php");
    }
    else {
        echo "Wrong Username or Password";
    }
   ?>

标头是要发送的第一件事。如果您打印文本然后发送标题,它将显示类似的错误。删除或注释页眉部分以查看是否正在打印错误