title: PHP - session multi user and admin privileges
body: <p>Can anyone help me?</p>
  
  <p>Im still newbie in using most of the php stuff here. I kinda having a problem with creating multi users using session.</p>
  
  <p>What I want to do is this. An account exclusive only of admin and an account only for normal users.</p>
  
  <p>Admin privileges will be able to access pages for admins only while normal users who logs in, will be able to access pages meant for users only.</p>
  
  <p>So far Ive created a single user login credentials. Which is for admins only. Im really confused how do I add non-admin in order to access pages only for them.</p>
  
  <p>Can anyone help me with this code?</p>
  
  <p>This is the home page</p>
  
  <pre><code>&lt;?php
  
  //Initialize Session
  session_start();
  
  error_reporting(E_ALL ^ E_NOTICE);
  
  //$name = $_SESSION['username'];
  if(isset($_SESSION['username']))
      {
          header('Location: index_admin.php');
      }
  ?&gt;
  </code></pre>
  
  <p>This is the admin page</p>
  
  <pre><code>&lt;?php
  // Inialize session
  session_start();
  
  // Check, if username session is NOT set then this page will jump to login page
  if (!isset($_SESSION['username']))
      {
          header('Location: index.php');
      }
  ?&gt;
  </code></pre>
  
  <p>This is the login form</p>
  
  <pre><code>&lt;form action="login.php" method="post"&gt;
  
                              &lt;input type="text" name="uname"     placeholder="USERNAME . . . "  autofocus/&gt;
                              &lt;br/&gt;
                              &lt;input type="password" name="pword"     placeholder="PASSWORD . . . " /&gt;
                              &lt;br/&gt;
                              &lt;center&gt;&lt;input type="submit" name="submit"     value="LOGIN" /&gt;&lt;button type="reset" value="Reset" /&gt;RESET&lt;/button&gt;&lt;/center&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>This is the login.php</p>
  
  <pre><code>&lt;?php
  session_start();
  
  include("config.php");
  
  $login = mysql_query("SELECT * FROM users WHERE (username = '" .     mysql_real_escape_string($_POST['uname']) . "') and (password = '" .     mysql_real_escape_string($_POST['pword']) . "')");
  // Check username and password match
  if (mysql_num_rows($login) == 1)
      {
          // Set username session variable
          $_SESSION['username'] = $_POST['uname'];
  
          // Jump to secured page
          header('Location: index_admin.php');
      }
  else 
      {
  
          // Jump to login page
  
          header('Location: index.php');
  
      }
      ?&gt;
  </code></pre>
  
  <p>This is the database</p>
  
  <pre><code>user_tbl
  
  
  id = 1
  
  
  username = admin
  
  
  password = 12345
  </code></pre>
  
  <p>Thanks in advance for the assitance.</p>