title: PHP webpage has a direct loop error?
body: <p>I have been trying to create a login page in PHP to no avail though, i have been getting a "This webpage has a redirect loop" error when i try to run it, so i was wondering if anyone could possibly spot  my mistakes? Here is my code:</p>
  
  <pre><code>&lt;?php
  require_once("nocache.php");
  $id = $_POST["id"];
  $pword = $_POST["pword"];
  if (!empty($_POST){
  if (!empty($id) || !empty($pword)){
  require_once("dbconn.php");
   $sql = "select username, school_type from school_info where username = '$id' and password = '$pword'";
   $rs = mysql_query($sql, $dbConn);
   if (mysql_num_rows($rs)&gt; 0 ) {
       session_start();
       $_SESSION["who"] = $id;
       $_SESSION["school_type"] = mysql_result($rs,0,"school_type");
       header("location: EOI_home.php");
      }
  }
  else {
  header("location: login.php");}     
  } else {
     header("location: login.php");}
  
  ?&gt;
  
  &lt;form method="POST" action="&lt;?php echo $_SERVER["PHP_SELF"];?&gt;" id="login"&gt;
  
  ID: &lt;input type="text" name="id" /&gt;&lt;br/&gt;
  pword: &lt;input type="password" name="pword" /&gt;&lt;br/&gt;
  
  &lt;input type="submit" value="log in" /&gt;&amp;nbsp;
  &lt;input type="reset" /&gt;
  
  &lt;/form&gt;
  </code></pre>