title: navigation menu based on user level
body: <p>Hi i am creating a navigation system based on user level. The code i made doen't show any error but its not displaying the menu. I dont know where i went wrong. I googled for this kind of menu but i couldn't find any solution. Can anyone sort the mistake i have made? Or tell me if there is anyother way to do it?</p>
  
  <p>Here is my code.</p>
  
  <pre><code>    &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Index&lt;/title&gt;
  &lt;/head&gt;
      &lt;body&gt;
  
  &lt;!--database connection--&gt;
  
  &lt;?php
  //error_reporting(0);
  'session_start()';
  $con = new mysqli('localhost', 'username', 'password', 'database');
  if($con-&gt;connect_errno &gt; 0){
      die('Sorry, We\'re experiencing some connection problems.');
  }
  ?&gt;
  
  &lt;!--functions--&gt;
  
  &lt;?php
      function loggedin(){
          if(isset($_SESSION['user_id'])){
              return true;
          }else{
              return false;
          }
      }
  ?&gt;
  
  
  &lt;!--titlebar--&gt;
  
  &lt;div&gt;
      &lt;?php
          if(loggedin()){
              $my_id=$_SESSION['user_id'];
              $log=$con-&gt;prepare("SELECT username,user_level FROM users WHERE user_id='$my_id'");
              $log-&gt;execute;
              $log-&gt;bind_result($username, $user_level,$my_id);
              $log-&gt;store_result;
              if($log-&gt;fetch()) //fetching the contents of the row
              {
                  if($user_level=='a'){?&gt;
                      &lt;a href = 'index.php'&gt;Home&lt;/a&gt;
                      &lt;a href = 'admin.php'&gt;Admin&lt;/a&gt;
                      &lt;a href = 'index.php'&gt;Log Out&lt;/a&gt;
                  &lt;?php
                  }if($user_level=='m'){?&gt;
                      &lt;a href = 'index.php'&gt;Home&lt;/a&gt;
                      &lt;a href = 'profile.php'&gt;Profile&lt;/a&gt;
                      &lt;a href = 'index.php'&gt;Log Out&lt;/a&gt;
                  &lt;?php
                  }else{?&gt;
                      &lt;a href = 'index.php'&gt;Home&lt;/a&gt;
                      &lt;a href = 'login.php'&gt;Login&lt;/a&gt;
                      &lt;a href = 'register.php'&gt;Register&lt;/a&gt;
              &lt;?php
              }
          }
          }
      ?&gt;
  
  &lt;/div&gt;
  Index
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I have used the same method for my login page which is working fine. This is my login page code.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;LOGIN&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;?php include 'connect.php';?&gt;
  &lt;?php include 'functions.php';?&gt;
  &lt;?php include 'titlebar.php';?&gt;
  
  &lt;h3&gt;LOGIN HERE:&lt;/h3&gt;
  &lt;form action ="" method="post"&gt;
  
  User Name:&lt;br/&gt;
  &lt;input type='text' name='username' /&gt;
  &lt;br/&gt;&lt;br/&gt;
  Password:&lt;br/&gt;
  &lt;input type='password' name='password' /&gt;
  &lt;br/&gt;&lt;br/&gt;
  &lt;input type='submit' name='submit' value='login'&gt;
  &lt;/form&gt;
  &lt;?php
  
  if(isset($_POST['submit'])){
      $username = $_POST['username'];
      $password = md5($_POST['password']);
  
  
      $stmt = $con-&gt;prepare("SELECT user_id, username, password, status FROM users WHERE username=? AND password=? LIMIT 1");
      $stmt-&gt;bind_param('ss', $username, $password);
      $stmt-&gt;execute();
      $stmt-&gt;bind_result($user_id, $username, $password, $status);
      $stmt-&gt;store_result();
      if($stmt-&gt;num_rows == 1)  //To check if the row exists
          {
              if($stmt-&gt;fetch()) //fetching the contents of the row
              {
                 if ($status == 'd') {
                     echo "YOUR account has been DEACTIVATED.";
                     exit();
                 } 
                 if ($status == 'b') {
                     echo "YOUR account has been BANNED.";
                     exit();
                 } 
                 if ($status == 'n') {
                     echo "YOUR account has NOT YET BEEN ACTIVATED.";
                     exit();
                 } 
                 else {
                     $_SESSION['Logged'] = 1;
                     $_SESSION['user_id'] = $user_id;
                     $_SESSION['username'] = $username;
                     echo 'Success!';
                     exit();
                 }
             }
  
      }
      else {
          echo "INVALID USERNAME/PASSWORD Combination!";
      }
      $stmt-&gt;close();
  }
  else 
  {   
  
  }
  $con-&gt;close();
  
  ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Any help would be appretiated.</p>
  
  <p>Thank You.</p>