title: PHP header redirection not working
body: <p>I have done my research - and have found multiple solutions to this question, but for whatever reason mine is still not working!</p>
  
  <p>Using IIS to host the site locally redirection works fine, however when I place it on my web server the redirection doesn't work.</p>
  
  <p>Below is a segment of the code from my 'myaccount.php' page.</p>
  
  <pre><code>&lt;?php
  session_start();
  if ($_SESSION['LoggedIn'] == true)
  {    
      // ... Display page... lots of code here
  }
  else
  // Session not active.
  {
      // Redirect to login page.
      header("Location: http://{$_SERVER['HTTP_HOST']}/2ndassign/login.php");
  }
  ?&gt;
  </code></pre>
  
  <hr>
  
  <p>When that page is hosted online I am simply presented with a blank 'myaccount.php'... no redirection takes place. There is no whitespace present which should cause it to have an error.</p>
  
  <p>So, I've cut my code down to this, so that it's as bare and simple as possible. Error reporting is on so it no longer presents a blank page, but spits out any errors.</p>
  
  <pre><code>&lt;?php
  error_reporting(E_ALL);
  ini_set('display_errors', 'On');
  header("Location:http://{$_SERVER['HTTP_HOST']}/2ndassign/login.php");
  ?&gt;
  </code></pre>
  
  <p>You can view the site at www.candlesoft.com.au/2ndassign/myaccount.php
  This might help you in helping me - to see what errors are being spat out.</p>
  
  <p>My guts tell me it's a setting with my hosting provider.</p>
  
  <p>CODE ON PASTEBIN - This is myaccount.php from www.candlesoft.com.au/2ndassign/myaccount.php - It is not an excerpt it is the entire file.
  (Shows whitespace isn't causing the error)
  <a href="http://pastebin.com/FUHPpT5A" rel="nofollow noreferrer">http://pastebin.com/FUHPpT5A</a></p>
  
  <hr>
  
  <p>Turns out the fault was that I needed to save the file as UTF-8 (without BOM)... PHP appears to interpret certain characters that BOM generates as whitespace - better explained here: <a href="https://stackoverflow.com/questions/8028957/headers-already-sent-by-php">How to fix &quot;Headers already sent&quot; error in PHP</a>
  Thanks to Billy2mates for the link!</p>