title: Login system with 3 levels of users PHP
body: <p>In my login system code i have 3 users.</p>
  
  <p>But other users can access my admin page.</p>
  
  <p>I want that my admin page can be accessible only for users that has the user level =1 that is the admin.</p>
  
  <p>my code.</p>
  
  <pre><code>&lt;?php
  session_start();
  include 'includes/dbh.php';
  //You can add more params here for more register options
  $email= $_POST['email'];
  $password= $_POST['password'];
  
  
  $sql =("SELECT * FROM usuarios WHERE email='$email' 
  AND password='$password'");
  $result = $conn-&gt;query($sql);
  if(!$row = $result-&gt;fetch_assoc()) {
  $_SESSION['errorLogin']="Usuario ou senha inválida";
  echo "".$_SESSION['errorLogin'];
  header("Location: login.php");
  
  }else{
  
  
  $_SESSION['userName']=          $row ['nome'];
  $_SESSION['userLName']=         $row ['sobrenome'];
  $_SESSION['userLevel']=         $row ['userLevel'];
  $_SESSION['useremail']=         $row ['email'];
  $_SESSION['password']=          $row ['password'];
  $_SESSION['userContact']=       $row ['contato'];
  $_SESSION['userContact2']=      $row ['contato2'];
  $_SESSION['role']=              $row ['login'];
    if($_SESSION['userLevel'] == 1){
     header("Location: adm/painel.php");
     }else{ header("Location: cliente.php"); 
  
     }
     if($_SESSION['userLevel'] == 2){
     header("Location: rep_page.php");
     }else{ header ("Location: rep_page.php");}
  
     if($_SESSION['userLevel'] == 3){
     header("Location: cliente.php");
  
     }else{
     echo "Your not logged in";
  
     }
     }
     ?&gt;
  </code></pre>
  
  <p>why other two users can access my admin page?
  whats wrong?</p>