title: control php page by different user level logged in (not working)
body: <p>Basically I try to make this code to navigate in a different php page..
  Thi is verify_user.php
          
  
  <pre><code>$con = mysqli_connect("localhost", "root", "****", "myDB");
  if (!$con){
      die("Connection to database failed: " . mysqli_connect_error());
  }
  
  $uname=$_POST['u_name'];
  $pass=$_POST['pass'];
  
  $qry = mysqli_query($con, "SELECT * FROM login WHERE user='$uname'");
  
  if(!$qry){
      die("Query Failed: ". mysql_error());
  } else {
      $row = mysqli_fetch_array($qry);
  
          if($_POST['u_name'] == $row["user"] &amp;&amp; $_POST['pass'] == $row["password"]) {
              if ($_POST['u_name'] = "admin") {
                  session_start();
                  $_SESSION['name'] = $_POST['u_name'];
                  header("Location:admin_panel.php");
              } else {    
                  session_start();
                  $_SESSION['name']=$_POST['u_name'];
                  header("Location:main.php");
              }       
          } else {
              header("Location:main.php?id=Worng ID / Password!");
          }
      }
      ?&gt;
  </code></pre>
  
  <p>From this code as we can see, if the user is admin, it should go to admin_panel.php. And if the user is not admin, its should go to main.php.
  For further explanation; thi is my admin_panel.php</p>
  
  <pre><code>&lt;?php
  session_start();
  if(isset($_SESSION['name'])){
     if(!$_SESSION['name']=='admin'){
  ?&gt;
  
  
  
  &lt;!-- HTMML CODE --&gt;
  
  
  
  &lt;?php
     }
     else
        header("Location:index.php?id=Only for admin.");
  }
  else
  {
  header("Location:index.php?id=Only for admin.");
  }
  ?&gt;
  </code></pre>
  
  <p>But its not working...</p>