title: Making a certain log in pattern go to another page location
body: <p>I am constructing a social networking site. Users who register and log in correctly are redirected to <code>home.php</code> with a <code>$_SESSION</code> made accordingly.</p>
  
  <p>But I have manually made an admin user with the username of <code>freddy</code> (the username is required to log in). What I am trying to state is that "if the username is equal to freddy, then take him to <code>admin_home.php</code>".</p>
  
  <p>What I have tried is to create two separate <code>$_SESSION</code>'s.</p>
  
  <p><strong><code>$_SESSION</code> created for normal user:</strong></p>
  
  <pre><code>    // if the user credentials are correct, log the user in:
          $_SESSION["user_login"] = $user_login;
              header( "Location: home.php" ); // refresh page
          exit;
      }   
  </code></pre>
  
  <p><strong><code>$_SESSION</code> created for admin:</strong>  </p>
  
  <pre><code>    if ($account_type == "admin"){
          // Create seperate session for admin
          $_SESSION["user_login"] = $admin_login;
                  header( "Location: admin_home.php" ); // refresh page
              exit;
          }   
  </code></pre>
  
  <p><strong>Full query:</strong></p>
  
  <pre><code>&lt;?php
  $user_query = mysqli_query ($connect, "SELECT * FROM users WHERE username = '$user_login' AND password = '$decrypted_password' AND closed='no' LIMIT 1");   
      $check_for_user = mysqli_num_rows ($user_query); // checking to see if there is infact a user which those credentials in the DB
          if ($check_for_user==1){
              while ($row = mysqli_fetch_array($user_query)){
                  $user_id = $row['id'];
                  $account_type = $row['account_type'];
              }
              // if the user credentials are correct, log the user in:
              $_SESSION["user_login"] = $user_login;
                  header( "Location: home.php" ); // refresh page
              exit;
          }   
  
          if ($account_type == "admin"){
              // Create seperate session for admin
              $_SESSION["user_login"] = $admin_login;
                      header( "Location: admin_home.php" ); // refresh page
                  exit;
              }           
  
          else {
                  // if user row does not equal 1 ...
                  echo "&lt;div class='wrong_login'&gt;
                          &lt;p&gt; Username or password is incorrect, please try again. &lt;/p&gt;
                       &lt;/div&gt;";       
              exit(); 
          }
  }
  ?&gt;  
  </code></pre>
  
  <p>With the current code, logging in with the username <code>freddy</code> - which should take me to <code>admin_home.php</code>, takes me to <code>home.php</code> which is not what I want.</p>