我有两个登录面板 - 一个使用usertypes作为单选按钮,一个用户名和密码,另一个只有用户名和密码。我写了下面的函数,但它不适合我。
function auth_check_user1($login, $password, $agent )
{
$userAndPassValid = ($f['login'] == $login && $f['password'] == $password);
$userTypeValid = true;
if ($agent != null)
{
$userTypeValid == $agent;
$query = 'SELECT * FROM ' . USERS_TABLE . ' WHERE login = "' . $login . '" AND
password ="' . $password . '" AND user_category ="' . $agent . '" LIMIT 1';
$r = $db->query ($query);
if ($db->num_rows($r)==1)
{
$f = $db->fetch_array($r);
if ($f['login'] == $login && $f['password'] == $password && $f['user_category'] == $agent)
$logged = TRUE;
else
$logged = FALSE;
}
else
{
$logged = FALSE;
}
return $logged;
}