title: Redirection doesnt work properly
body: <p>I was trying to redirect an html page to two different php files. 
  Html file which i created is <code>redirect.html</code>. When i go to that page it would check if i was logged in or not, if i was not it would take me to <code>ucplogin.php</code>
  on the other hand if i was logged in it'd take me to <code>ucphome.php</code>.
  Here the problem is the code i'm trying is obviously messed up because i've been trying for a while and still doesnt work</p>
  
  <pre><code>&lt;?php
  session_start();
  ?&gt;
  
  &lt;!DOCTYPE HTML&gt;
  &lt;html lang="en-US"&gt;
      &lt;head&gt;
          &lt;meta charset="UTF-8"&gt;
          &lt;meta http-equiv="refresh" content="1;url=http://example.com"&gt;
          &lt;script type="text/javascript"&gt;
  
  
              &lt;?php
              if(!isset($_SESSION['playername']))
              {
              ?&gt;
              window.location.href = "http://localhost/working/ucplogin.php"
              &lt;?php
              }
              else
              {
              ?&gt;
              window.location.href = "http://localhost/working/ucphome.php"
              &lt;?php
              }
              ?&gt;
  
          &lt;/script&gt;
          &lt;title&gt;Page Redirection&lt;/title&gt;
      &lt;/head&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>EDIT:
  I have seen all those answers and got some points but i rewrite the code to this</p>
  
  <pre><code> &lt;?php
  session_start();
  ?&gt;
  
  &lt;?php
      if(!isset($_SESSION['playername']))
      {
      ?&gt;
      header('Location: http://localhost/working/ucplogin.php');
      &lt;?php
      }
      else
      {
      ?&gt;
      header('Location: http://localhost/working/ucphome.php');
      &lt;?php
      }
  ?&gt;
  </code></pre>
  
  <p>when i go to redirect.php it gives me header('Location: <a href="http://localhost/working/ucphome.php" rel="nofollow">http://localhost/working/ucphome.php</a>');  when i'm logged in and this when i'm not <code>header('Location: http://localhost/working/ucplogin.php');</code></p>
  
  <p>Apparently it works but technically not, it doesn't redirect me to the exact page.</p>