Working on a Project which have several admins and one super admin.. I have created a common table for admin's. Tables have fields username,password,location and status.
I have created a single login page. For admin I need username and location in session.But for super admin I need only username in session.The problem is that while logging in for any admin/superadmin it opens in a same page..i.e s_activity.php. The php code is as shown below:
<?php
include("connect.php");
session_start();
$Username=$_POST["t1"];
$Password=$_POST["t2"];
$Status=$_POST["t3"];
$location=$_POST["l1"];
$q=mysql_query("select * from admin_login where username='$Username'");
$rs=mysql_fetch_row($q);
if(($rs[0]==$Username)&&($rs[1]==$Password)&&($rs[4]==$location)&&($rs[3]==$Status))
{
if($_SESSION["status"]=admin)
{
$_SESSION["user"]=$Username;
$_SESSION["location"]=$location;
echo "<script type='text/javascript' language='javascript'>
alert('Admin logged in successfully');
</script>";
header("Refresh:0;http://localhost/e_classified/admin/a_activity.php");
}
else
{
echo "<script type='text/javascript' language='javascript'>
alert('Incorrect details, Enter correct details');
</script>";
header("Refresh:0;http://localhost/e_classified/super admin/login.html");
}
}
if(($rs[0]==$Username)&&($rs[1]==$Password)&&($rs[3]==$Status))
{
if($_SESSION["status"]==sadmin)
{
$_SESSION["user"]=$Username;
echo "<script type='text/javascript' language='javascript'>
alert('Super Admin logged in successfully');
</script>";
header("Refresh:0;http://localhost/e_classified/super%20admin/s_activity.php");
}
else
{
echo "<script type='text/javascript' language='javascript'>
alert('Incorrect details, Enter correct details');
</script>";
header("Refresh:0;http://localhost/e_classified/super admin/login.html");
}
}
?>