title: Writing an 'if' statement in order to login users using php/ mysql
body: <p>I’m wondering how you write if statements using mysql/php.</p>
  
  <p>I’ve got an employee table with all their details, ‘username’ and ‘password’ then a column called ‘admin’ with a 0 or 1 as well. The user can login using the "username" and "password" form boxes. How do I write it so that it checks if the username/password exists then checks if admin = 0 and directs them  to header location employee.php  else if admin=1 then directs them to header location admin.php?</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>edit: This is the code I've got so far...</p>
  
  <pre><code>$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
  
  $result=mysql_query($sql);
  
  $count=mysql_num_rows($result);
  
  if($count==1){
      setcookie('username',$myusername,time() + (86400 * 7)); // 86400 = 1 day
  
  if ('admin' == '0'){
  
  
  header("location:employee.php");
  
  }
  
  else {
  
  header("location:admin.php");
  
  else {
  
  header("location:fail.php");
  }
  }
  
  ?&gt;
  </code></pre>