Basically I try to make this code to navigate in a different php page.. Thi is verify_user.php
$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"] && $_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!");
}
}
?>
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
<?php
session_start();
if(isset($_SESSION['name'])){
if(!$_SESSION['name']=='admin'){
?>
<!-- HTMML CODE -->
<?php
}
else
header("Location:index.php?id=Only for admin.");
}
else
{
header("Location:index.php?id=Only for admin.");
}
?>
But its not working...