title: Error: "Cannot modify header information - headers already sent by ...."
body: <p>I'm developing a website and I purchased MAMP PRO. When I try to login through login_user.php:</p>
  
  <pre><code>if (empty($_POST)===false){
  $username = $_POST['username'];
  $password = $_POST['password'];
  
  
  if (empty($username) === true || empty ($password) === true){ 
  
      $errors[] = 'You need to enter a username and password';
  } else if (user_exists($username) === false){
      $errors[] = 'we can\'t find that username. have you registered?';
  }else if (user_active($username) === false){
      $errors[] = 'you haven\'t activated your account!';
  }else {
  $login = login($username, $password);
  if ($login === false){
      $errors[] = 'username/password combination is incorrect!';
  }else {
  
     //set user session 
  $_SESSION['user_id'] = $login;
  //redirect user to home
  header('Location: home.php');
  exit();
      }
  
      }
  print_r($errors);
      }
       ?&gt;
  </code></pre>
  
  <p>the user should be redirected to home.php.</p>
  
  <p>It used to work perfectly on the server I was using before but now I get just a white page (it stay basically on login_user.php) when I test it on my local machine. 
  The connection to the database works fine. Does Header work properly on MAMP? I'm able to set the session and destroy it in logout.php but both files don't redirect after having set or destroyed the session. Any clue?</p>
  
  <p>UPDATE: I get this error:</p>
  
  <pre><code>Warning: Cannot modify header information - headers already sent by (output started at   /Applications/MAMP/htdocs/mywebsite/core/database/databaseconn.php:2) in /Applications/MAMP/htdocs/mywebsite/login_user.php on line 26
  </code></pre>
  
  <p>FIXED IT!!!
  the problem was that in databaseconn.php I left blank  the first line before <code>&lt;?php</code><br>
  I can't believe it. ;-)</p>