我正在创建具有不同用户级别的登录名。如果用户名和密码是 admin 或 staff,如何从我的表 users 中获取 user_level 字段。
这是代码:
<?php
include("../config/database.php");
if(isset($_POST["login"]))
{
$username = $_POST['username'];
$password = $_POST['password'];
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$query = "SELECT * FROM users
WHERE username= '$username' OR email= '$username'
AND password='$password'";
$result = mysql_query($query);
$count = mysql_num_rows($result);//counting table rows
if($count==1)
{//check if found username and password
if(user_level == "admin")
{
header("Location: ../views/admin/dashboard.php");
}
elseif(user_level=="patient")
{
header("Location: ../views/default/home.php");
}
}
else
{
echo "WRONG USERNAME OR PASSWORD!";
}
}
?>