title: PHP - login admin/user
body: <p>I am new to php
   I have a problem with code - 
  I want to make one more condition in IF to login as an admin - <strong>$login="Admin"</strong> 
  so I write <strong>if($ilu_userow>0 &amp;&amp; $login="Admin")</strong> 
  instead of <strong>if($ilu_userow>0)</strong> and it does not work - it doesn't see that condition and if the login is <strong>user</strong> it is logging too.</p>
  
  <pre><code>&lt;?php
  
  session_start();
  
  if ((!isset($_POST['login'])) || (!isset($_POST['haslo'])))
  {
      header('Location: index.php');
      exit();
  }
  
  require_once "connect.php";
  
  $polaczenie = @new mysqli($host, $db_user, $db_password, $db_name);
  
  if ($polaczenie-&gt;connect_errno!=0)
  {
      echo "Error: ".$polaczenie-&gt;connect_errno;
  }
  else
  {
      $login = $_POST['login'];
      $haslo = $_POST['haslo'];
      $login = htmlentities($login, ENT_QUOTES, "UTF-8");
      $haslo = htmlentities($haslo, ENT_QUOTES, "UTF-8");
  
      if ($rezultat = @$polaczenie-&gt;query(
      sprintf("SELECT * FROM uzytkownicy WHERE user='%s' AND pass='%s'",
      mysqli_real_escape_string($polaczenie,$login),
      mysqli_real_escape_string($polaczenie,$haslo))))
      {
          $ilu_userow = $rezultat-&gt;num_rows;
  
  
  
         if($ilu_userow&gt;0)
  
  
     {
  
  
              $_SESSION['zalogowany'] = true;
  
              $wiersz = $rezultat-&gt;fetch_assoc();
  
              $_SESSION['id'] = $wiersz['id'];
              $_SESSION['user'] = $wiersz['user'];
              $_SESSION['drewno'] = $wiersz['drewno'];
              $_SESSION['kamien'] = $wiersz['kamien'];
              $_SESSION['zboze'] = $wiersz['zboze'];
              $_SESSION['email'] = $wiersz['email'];
              $_SESSION['dnipremium'] = $wiersz['dnipremium'];
  
              unset($_SESSION['blad']);
              $rezultat-&gt;free_result();
  
                  header('Location: gra.php'); }
  
  
           else {
  
  
              $_SESSION['blad'] = '&lt;span style="color:red"&gt;Nieprawidłowy login lub hasło!&lt;/span&gt;';
              header('Location: index.php'); }
              }
      }
  
              default;
  
  
  
  
      $polaczenie-&gt;close();
  }
  </code></pre>
  
  <p>?></p>