title: login page redirect php
body: <p>My page was working properly when it had a single page . Once I added the redirect to another page it seems the remember me checkbox no longer works. I am not sure if the exit command is affecting it once I remove the else and exit on both then it remembers.
  I am trying to make an admin user profile.
  Admin = 1
  user = 0 </p>
  
  <p>I tried removing the exit; and the redirects.</p>
  
  <p>But I really want to keep them </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
    &lt;head&gt;
  &lt;!-- Bootstrap core CSS --&gt;
      &lt;link href="bootstrap.min.css" rel="stylesheet"&gt;
    &lt;/head&gt;
  
  &lt;style&gt;
  .alert {
      text-align: center;
      padding: 12px;
      background-color: #f44336; /* Red */
      color: white;
      margin-bottom: 10px;  
  }
  &lt;/style&gt;
  
  
  &lt;?php
  session_start(); // Starting Session
  $error=''; // Variable To Store Error Message
  
  if (isset($_POST['submit'])) {
  if (empty($_POST['username']) || empty($_POST['password'])) {
  $error = "Username or Password is invalid";
  }
  else
  {
  
  // Define $username and $password
  $username=$_POST['username'];
  $password=$_POST['password'];
  
  // Establishing Connection with Server by passing server_name, user_id and password as a parameter
  
  $connection = mysql_connect("localhost", "root", "password");
  
  // To protect MySQL injection for Security purpose
  
  $username = stripslashes($username);
  $password = stripslashes($password);
  $username = mysql_real_escape_string($username);
  $password = mysql_real_escape_string($password);
  
  // Selecting Database
  $db = mysql_select_db("kike", $connection);
  // SQL query to fetch information of registerd users and finds user match.
  
  $query = mysql_query("select * from login where password='$password' AND username='$username'", $connection);
  $rows = mysql_num_rows($query);
  
  if ($rows == 1) {
  
  
  $query = mysql_query("select * from login where password='$password' AND username='$username' AND admin = 1", $connection);
  $master = mysql_num_rows($query);
  
  
       $_SESSION['login_user']=$username; // Initializing Session
  
          if($master == 1) { // some way of identifying an admin
              // admin
  
              header("location: wood/profile.php"); // Redirecting To Other Page
              exit;
          } else {
              // user
              header("location: user/profile.php");
              exit;
          }
  
  $_SESSION["id"]= $user["id"];
  
              if(!empty($_POST["remember"])) {
                  setcookie ("username",$_POST["username"],time()+ (10 * 365 * 24 * 60 * 60));
                  setcookie ("password",$_POST["password"],time()+ (10 * 365 * 24 * 60 * 60));
              } else {
                  if(isset($_COOKIE["username"])) {
                      setcookie ("username","");
                  }
                  if(isset($_COOKIE["password"])) {
                      setcookie ("password","");
                  }
              }
                    } 
  
  else {
  $error = "Username or Password is invalid";
  
  echo ' &lt;div class="fixed-top"&gt;
  
  &lt;div class="alert alert-primary"  role="alert"&gt;
    Invalid username or password
  &lt;/div&gt; &lt;/div&gt;' ;
  
  }
  
  mysql_close($connection); // Closing Connection
  }
  }
  ?&gt;
  
  &lt;/html&gt;    
  </code></pre>