我有此代码
function login(){
global $db, $errors, $disable;
if (isset($_POST['username'])) {
$stmt = $db->prepare("SELECT id, password, user_status, user_type FROM users WHERE username=?");
$stmt->bind_param("s", $_POST['username']);
$stmt->execute();
$stmt->bind_result($id, $hashed_password, $user_status, $user_type);
if ($stmt->fetch() && password_verify($_POST['password'], $hashed_password)) {
if ($user_status == 'Active') {
$_SESSION['user'] = $user_type;
} else {
$disable[] = "Your Account has been disabled";
}
} else {
$errors[] = "Wrong username/password combination";
}
$stmt->close();
}
}
问题是我无法回显我具有列名“ user_type”的角色,并且它具有两种用户类型,即admin和user。但是我不知道为什么会得到这个错误,我在PDO中出现了新错误,我不知道我的代码有什么问题,我在$_SESSION['user'] = $user_type;