Can you see what's wrong with my simple php code?
<p>I just can't figure out why I am getting this error:</p>

<blockquote>
  <p>Warning: Cannot modify header
  information - headers already sent by
  (output started at
  C:\Users\Gateway\Documents\xampp\htdocs\login.php:3)
  in
  C:\Users\Gateway\Documents\xampp\htdocs\login.php
  on line 14</p>
</blockquote>

<p>Here's the code:</p>

<pre><code>if (isset($_POST['submit'])) {

    $username = sanitize($_POST['username']);
    $password = sanitize($_POST['password']);

    if ($username) {
        if ($password) {
            $query = mysql_query(" SELECT * FROM users WHERE username = '$username' &amp;&amp; password = '$password' ");
            if (mysql_num_rows($query) == 1) {
                $setCookie = setcookie('loggedIn', 1, time()+3600);
                echo 'user found';
            } else {
                $error = 'The username and/or password you entered is incorrect';
            }
        } else {
            $error = 'Please enter a password';
        }
    } else {
        $error = 'Please enter a username';
    }

}
</code></pre>

<p>I am entering the username 'admin' and the password '123', a record for this exists in my database inside the users table. And the "user found" message I'm echoing works when the correct username/password combo is entered. </p>

<p>Problem is, the cookie called "loggedIn" doesn't set and I get that can't modify header error.</p>

<p>Why?</p>
