title: Multiple login in PHP form not working
body: <p>The else part of my code is working when the password is wrong. However, when password is correct it does not go to the admin.php page. It just stays on the same page.</p>
  
  <p>Does anyone know why this is happening?</p>
  
  <pre><code>&lt;?php
  
  session_start();
  error_reporting(E_ALL); // to see if there is error in code
  
  include "connect_to_mysql.php";
  if(isset($_POST['log'])){
      $user = $_POST['user'];
      $pass = md5($_POST['pass']);
      $sql  = mysql_query("select * from login where user= '$user' AND pass='$pass' LIMIT 3 ") or die( mysql_error());
      $data = mysql_fetch_array($sql);
      $UserName = $data['user'];
      $Password = $data['pass'];
      $type = $data['type'];
      $name = $data['name'];
      if($user==$UserName &amp;&amp; $pass==$Password){
          session_start();
          $_SESSION['name']=$name;
          if($type=='admin'){
              header("location: admin.php");
          }else if($type=='vender1'){
              header("location: vender1.php");
          }
  
      }
  }
  ?&gt;
  </code></pre>
  
  <p>The database contains: id, name, user, pass, type</p>
  
  <p>So my problem is; after the right password is entered, the same page remains open, but it should open admin.php.</p>
  
  <pre><code>   &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
    &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
    &lt;head&gt;
     &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
      &lt;title&gt; Log In &lt;/title&gt;
    &lt;link rel="stylesheet" href="style.css" type="text/css" media="screen" /&gt;
    &lt;/head&gt;
  
    &lt;body&gt;
    &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
      &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
    &lt;div id="mainWrapper"&gt;
     &lt;?php include_once("header.php") ?&gt;
    &lt;div id="pageContent"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
     &lt;div align="right" style="margin-right:24px; color:#FF0000"&gt;
     &lt;h2&gt;Please Log In To Manage the Inventary&lt;/h2&gt;
     &lt;br /&gt;&lt;br /&gt;
     &lt;form id="form" name="form" method="post" action="login.php"&gt;
      &lt;h2 style="padding-right:200px;"&gt;User Name:&lt;/h2&gt;
        &lt;input name="user" type="text" id="user" size="40" style="height:20px;" /&gt;
       &lt;br /&gt;&lt;br /&gt;
       &lt;h2 style="padding-right:210px;"&gt;Password:&lt;/h2&gt;
      &lt;input name="pass" type="password" id="pass" size="40" style="height:20px;" /&gt;
     &lt;br /&gt;
     &lt;br /&gt;
     &lt;br /&gt;
  
       &lt;input type="submit" name="log" id="log" value="Log In" /&gt;
  
    &lt;/form&gt;
     &lt;p&gt;&amp;nbsp; &lt;/p&gt;
    &lt;/div&gt;
   &lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &lt;/div&gt;
  
   &lt;/div&gt;
   &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>
  
  <p>I am stuck here.. Please get me out from here.</p>