title: Multi-level login in PHP
body: <p>Im trying to develop a PHP system which enables multilevel login purposes.I want to use enum in my PHPMyAdmin, for the different levels of users.
  here is the login script:</p>
  
  <pre><code>&lt;?php
  session_start(); // Starting Session
  
  $error=''; // Variable To Store Error Message
  $empty='';
  $no_acc='';
  if (isset($_POST['submit'])) 
  {   
  if (empty($_POST['username']) || empty($_POST['password'])) {
  $empty = "Username or Password cannot be empty.";
  
  }
  else
  {
  // Define $username and $password
  $username=$_POST['username'];
  $password=$_POST['password'];
  $type='';
  
  // Establishing Connection with Server by passing server_name, user_id and password as a parameter
  $connection = mysql_connect("localhost", "root", "");
  
  
  // Selecting Database
  $db = mysql_select_db("swmlibrary", $connection);
  
  // To protect MySQL injection for Security purpose
  $username = stripslashes($username);
  $password = stripslashes($password);
  $username = mysql_real_escape_string($username);
  $password = mysql_real_escape_string($password);
  // SQL query to fetch information of registerd users and finds user match.
  $query = mysql_query(" SELECT `id` FROM `users` WHERE `username` = '".$username."' AND  `password` = '".$password."' ");
  $rows = mysql_num_rows($query);
  
  $data = mysql_fetch_array($query);
  $type = $data['type'];  
  $user = $data['username'];      
  if ($rows == 1) 
  {
  $_SESSION['username'] = $data['username'];
      if($type=='Super User')
          {   
               $_SESSION['login_user'] = $username;
               echo "&lt;script&gt;location.assign('./rootSU/super_user.php')     &lt;/script&gt; ";
  
              //header("location: ./rootSU/super_user.php");
          }
      elseif ($type=='Administrator')
          {
              $_SESSION['login_user']=$username; // Initializing Session
              echo "&lt;script&gt;location.assign('./admini/admin.php')&lt;/script&gt; ";
              //header("location: ./admini/admin.php");   
          }
      elseif ($type=='User')
          {
  
              $_SESSION['login_user']=$username; // Initializing Session
              echo "&lt;script&gt;location.assign('./user/home.php')&lt;/script&gt; ";
  
              //header("location: ./user/home.php"); 
          }
      else
      {
          $no_acc = 'It seems as if you do not have an account. Click &lt;a href="sign_form.php"&gt;here&lt;/a&gt; to sign up.';  
      }
  
  }
  else 
  {
  $error = "Incorrect Username or Password. Please try again.";
  }
  mysql_close($connection); // Closing Connection
  }  
  }           
  
  ?&gt;
  </code></pre>
  
  <p>Its not picking up the user type,displaying the error that there is no account,redirecting me to the sign_form.php page. What im i missing here?</p>