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,passwo
rd,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/superadmi
n it opens in a
same page..i.e
s_activity.php.
The php code is
as shown
below:
Code:
<?php
include("c
onnect.php"
;);
session_start(
);
$Username=$_POS
T["t1"
;];
$Password=$_POS
T["t2"
;];
$Status=$_POST[
"t3"]
;
$location=$_POS
T["l1"
;];
$q=mysql_query(
"select *
from
admin_login
where
username='$User
name'");
$rs=mysql_fetch
_row($q);
if(($rs[0]==$Us
ername)&&am
p;($rs[1]==$Pas
sword)&&
;($rs[4]==$loca
tion)&&
($rs[3]==$Statu
s))
{
if($_SESSION[&
quot;status&quo
t;]=admin)
{
$_SESSION["
;user"]=$U
sername;
$_SESSION["
;location"
]=$location;
echo
"<scrip
t
type='text/java
script'
language='javas
cript'>
alert('Admin
logged in
successfully');
</script>
";
header("Re
fresh:0;http://
localhost/e_cla
ssified/admin/a
_activity.php&q
uot;);
}
else
{
echo
"<scrip
t
type='text/java
script'
language='javas
cript'>
alert('Incorrec
t details,
Enter correct
details');
</script>
";
header("Re
fresh:0;http://
localhost/e_cla
ssified/super
admin/login.htm
l");
}
}
if(($rs[0]==$U
sername)&&a
mp;($rs[1]==$Pa
ssword)&&am
p;($rs[3]==$Sta
tus))
{
if($_SESSION[&q
uot;status"
;]==sadmin)
{
$_SESSION["
;user"]=$U
sername;
echo
"<scrip
t
type='text/java
script'
language='javas
cript'>
alert('Super
Admin logged in
successfully');
</script>
";
header("Re
fresh:0;http://
localhost/e_cla
ssified/super%2
0admin/s_activi
ty.php");<
br />
}
else
{
echo
"<scrip
t
type='text/java
script'
language='javas
cript'>
alert('Incorrec
t details,
Enter correct
details');
</script>
";
header("Re
fresh:0;http://
localhost/e_cla
ssified/super
admin/login.htm
l");
}
}
?>
|