PHP Warning : cannot modify header information
<p>I have an php login function. When I try to logged in with correct user, it show the error like this : </p>

<p>Warning: Cannot modify header information - headers already sent by (output started at /home/hapshou1/public_html/index.php:15) in /home/hapshou1/public_html/index.php on line 150</p>

<p>-</p>

<pre><code>include "config.php";

if($_SERVER["REQUEST_METHOD"] == "POST")
{
    function antiinjection($data)
    {
        $filter_sql = mysql_real_escape_string(stripslashes(strip_tags(htmlspecialchars($data,ENT_QUOTES))));
        return $filter_sql;
    }

    $username = antiinjection($_POST['username']);
    $pass = antiinjection($_POST['password']);

    $login=mysql_query("SELECT username, password FROM user WHERE (username='$username' OR email='$username') AND password='$pass'");
    $found=mysql_num_rows($login);
    $r=mysql_fetch_array($login);

    if
    ((!empty($username)) &amp;&amp;
    (!empty($pass)))
    {
        if ($found &gt; 0)
        {
            session_register("username");
            session_register("password");

            $_SESSION[username]     = $r[username];
            $_SESSION[password]     = $r[password];

            date_default_timezone_set("Asia/Jakarta");
            $date_log = date("j-F-Y, G:i ");

            mysql_query("update user set status='online', date_logged_in='$date_log' WHERE username='$_SESSION[username]'");
            header('location:home');
        }
        else
        {
            echo '&lt;div class="error_log"&gt;
                    &lt;p&gt;Wrong username or password. Please try again.&lt;/p&gt;
                &lt;/div&gt;';
        }
    }
    else
    {
        echo '
            &lt;div class="error_log"&gt;
                &lt;p&gt;Username and password are required.&lt;/p&gt;
            &lt;/div&gt;
        ';
    }
}
</code></pre>

<p>What's wrong with my code?</p>
