title: PHP Mysql Multiple Users Login Form
body: <p>How can I detect if the user is admin or customer? The code shown below has an if else statement which is considered to be wrong because I dont know what is the code for it could you please guys help me? I wanted to check the <code>$confirmation</code> variable. If it contains 1, the user will go to the admin page. If not then goes to the customer page. How should I do this? Btw the if is the admin and then the first else is the customer in the if else statement.</p>
  
  <p>PHP code:</p>
  
  <pre><code>&lt;?php
  session_start();
  
  include("dbcon.php");
  $username = $_POST['username'];
  $password = $_POST['password'];
  $qry="SELECT * FROM admininfo WHERE username='$username' AND password='$password'";
  $result=mysql_query($qry);
      if($result) {
      if(mysql_num_rows($result) == 1) {
          session_regenerate_id();
          $user = mysql_fetch_assoc($result);
          //$_SESSION['fname'] = $user['fname'];
          //$_SESSION['lname'] = $user['lname'];
          //$_SESSION['username'] = $user['username'];
          //$_SESSION['password'] = $user['password'];
          $_SESSION['confirmation'] = $user['confirmation'];
  
          session_write_close();
          header("Location:menu.php");
          exit();
      }else {
          header("Location:menu1.php");
          exit();
      }
  }else {
      die("Query failed");
  }
  ?&gt;
  </code></pre>