0

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");

}

}

?>
2
Contributors
1
Reply
20
Views
2 Years
Discussion Span
Last Post by prasaddlv
0

You need to join two if conditions at lines 11 and 30 by using elseif at line 30.

Also take care of using comparison operator at 13. Currently, it is using assignment operator.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.