-1

我已经为我的应用程序使用了登录名..首先我只使用了管理员登录名并且它工作得很好,但是现在当我也添加了教师和学生登录名时,但我发现一个问题,它没有登录我的旅馆。,,但只是重定向到未经授权的访问请求帮助

登录.php

<?php include("../includes/config.php");?>

<!DOCTYPE HTML>
<html>
<head>
<title>Admdin Login</title>
</head>
<body>
    <form method="post" action="login-action.php">
    <label>User Name:</label> <input type="text" name="un" />
    <label>Password:</label> <input type="password" name="pd" />  <br /><br />
    <input type="submit" value="Login" />
</form>

<a href="forgot-password.php">Forgot Password?</a>
</body>
</html>

这是登录-action.php

<?php include("../includes/config.php");?>
<?php

$uid=$_POST["un"];
$pwd=$_POST["pd"];
$encpwd=md5($pwd);
$con=mysql_connect($dbserver,$dbusername,$dbpassword);
if (!$con) { die('Could not connect: ' . mysql_error()); }

mysql_select_db($dbname, $con);

$result = mysql_query("SELECT * FROM accounts WHERE (email='".$uid."' AND   password='".$encpwd."')");

$num_rows = mysql_num_rows($result);
if ($num_rows > 0) {

while($row = mysql_fetch_array($result))
{
   $_SESSION['firstname'] = $row['firstname'];
   $_SESSION['lastname'] = $row['lastname'];
   $_SESSION['type'] = $row['type'];
   $_SESSION['id'] = $row['id'];
   $_SESSION['email'] = $row['email'];

   $_SESSION["loggedin"]=true;
}
}
else {
 $_SESSION["loggedin"]=false;
}

mysql_close($con);

if ($_SESSION["loggedin"])
{
if ($_SESSION["type"]=="A")
    {
        $_SESSION["isadmin"]=true;
    }

if ($_SESSION["type"]=="T")
    {
        $_SESSION["isteacher"]=true;
    }
if ($_SESSION["type"]=="S")
     {
         $_SESSION["isstudent"]=true;
     }

 }
if ($_SESSION["isadmin"])
{
header("Location: $fullpath"."admin/000.php");
}

if ($_SESSION["isteacher"])
{
header("Location:$fullpath"."teacher/");
}

if ($_SESSION["isstudent"])
{
header("Location:$fullpath"."student/");
}

else {
   header("Location: $fullpath"."login/unauthorized.php");
}
?>
4

1 回答 1

0
    if ($_SESSION["isadmin"])
    {
        header("Location: $fullpath"."admin/000.php");
    }

    elseif ($_SESSION["isteacher"])
    {
        header("Location:$fullpath"."teacher/");
    }

    elseif ($_SESSION["isstudent"])
    {
        header("Location:$fullpath"."student/");
    }

    else {
        header("Location: $fullpath"."login/unauthorized.php");
    }
于 2012-08-30T15:21:52.113 回答