I'm a newbie in php and I want to create a single login page for Admin and user.When admin log in it should go to an admin page and when user log it shoult go to index page.I want help with my code, it works fine login normal users but i try it addind the admin part and it doesn't seem to work .Please help and Thanks in advance ..
This is my validation code for the login
<?php
if(!empty($_POST)){
if(isset($_POST["username"]) &&isset($_POST["password"])){
if($_POST["username"]!=""&&$_POST["password"]!=""){
include "conexion.php";
$user_=null;
$sql1= "select * from user where (username=\"$_POST[username]\" or email=\"$_POST[username]\") and password=\"$_POST[password]\" ";
$query = $con->query($sql1);
while ($r=$query->fetch_array()) {
$user_fullname=$r["fullname"];
$_SESSION['user']=array();
}
if($user_fullname==null){
print "<script>alert(\"User or password incorrect.\");window.location='../login.php';</script>";
}else{
session_start();
$_SESSION["user_fullname"]=$user_fullname;
print "<script>window.location='../index.php';</script>";
}
}
}
}
?>