title: Do all header("Location: member.php?id=$username") have to be the first thing in a script? (PHP)
body: <p>I know in the Manuel it says that the header has to be the first thing in a script, but how come I see some codes where <strong>header("Location: member.php?id=$username")</strong> is in a if-statement?</p>
  
  <p>Ex:</p>
  
  <pre><code>//a bunch of codes above
  
  if($result!="0"){ 
  // authenication correct lets login
  $_SESSION["password"] = $password;;
  $_SESSION["username"] = $username;
  header("Location: member.php?id=$username");
  }
  else 
  {
      echo "Wrong username or password. Please try again!";
  }
  </code></pre>
  
  <p>But when I do this, it sometimes would/won't throw an error. 
  How do I allow the header (); to be used in a script without any errors?
  I want to redirect the user back to the login if they click "no" and to the homepage if they click "yes".</p>