Php 会话标头已发送错误

esa*_*wan 0 php session header

可能重复:
php 标头已发送错误

我已附上我的代码,该代码用于 php 中的非常基本的登录。它给出了一个错误

无法发送会话 cookie - 标头已发送(输出从 C:\xampp\htdocs\netsentries\f\includes\functions.php:1 开始)

   <?php 
    if (!isset($_POST['username'])) {
    ?>
    <h3>Login</h3>
    <form action="" method="post">
    Username<br/>
    <input name="username" type="text" /><br/>
    Password<br/>
    <input name="password" type="password" /><br/>
    <input name="" type="submit" /><br/>
    </form>
    <?php
    }
     else 
    { 
    include('includes/config.php');

    $data['username']= $_POST['username'];
    $data['password']= md5($_POST['password']);

    connect($db_name,$db_user,$db_pass,$db_host);

    $query= "select * from user where username='" . $data['username'] . "' AND password='" . $data['password'] . "'";

        $result=mysql_query($query);
        //check that at least one row was returned
        $rowCheck = mysql_num_rows($result);
        if($rowCheck > 0)
        {
        while($row = mysql_fetch_array($result))
            {
            session_start();
            session_register($data['username']);
            //successful login code will go here...
            //echo 'Logged in!'; 
            }
        }
        else
        {
        echo "Failed!";
        }



    }
    ?>
Run Code Online (Sandbox Code Playgroud)

我无法找出问题所在

Ry-*_*Ry- 5

session_start输出任何 HTML 后就不能再这样做了。将session_start调用移至顶部,并保留一个变量以供稍后回显的内容。任何不重要的东西<?php ?>,甚至是你的包含文件。