title: Object Moved page on PHP login script
body: <p>I've put together a login script, and by put together I mean I copy and pasted bits and pieces of code from forums and got it working from trial and error.</p>
  
  <p>So far the script is working fine, when logging in there is no issue at all, the only problem comes from when you try to login without filling in any of the fields, it gives me some strange error and redirects me to a blank page with</p>
  
  <blockquote>
    <p>Object Moved</p>
    
    <p>This document may be found here</p>
  </blockquote>
  
  <p>It's not a huge issue as I don't see why people would try and login with blank fields anyway, but it's something I'd like to know how to solve for future reference.</p>
  
  <p>Below is the login portion of my code:</p>
  
  <pre><code>&lt;?php
  session_start();
  
  $data=array("user1"=&gt;array("url"=&gt;"page1.php","password"=&gt;"12345"),
              "user2"=&gt;array("url"=&gt;"page2.php","password"=&gt;"12345"),
          "user3"=&gt;array("url"=&gt;"page3.php","password"=&gt;"12345")
          );
  
  if(isset($_POST['username']) &amp;&amp; isset($_POST['password'])) {
  
      $user = strtolower($_POST['username']);
      $pass = strtolower($_POST['password']);
  
      if($data[$user]['password'] == $pass) {     
         $_SESSION['username'] = $user . " " . $pass;
         header('Location: ' . $data[$user]['url']);
      } else {
          echo '&lt;script type="text/javascript"&gt;window.onload = function() { document.getElementById("loginError").innerHTML = "' . "Invalid login details. Please try again." . '"; }&lt;/script&gt;';
          logIn();
      }
  } else {
      logIn();
  }
  ?&gt;
  </code></pre>