Reputation: 546
The code that I have is this:
if(isset($_SESSION['id']) && isset($_SESSION['username'])){
$user_status = $db->prepare("SELECT `user_status` FROM `users` WHERE `id` = :id AND `username` = :username");
$user_status->bindValue(":id",$_SESSION['id'],PDO::PARAM_STR);
$user_status->bindValue(":username",$_SESSION['username'],PDO::PARAM_STR);
$user_status = $user_status->fetchColumn();
if($user_status == 0){
header("Location: /logout");
}elseif($user_status == 8 || $user_status == 9){
$links = '(<a href="/admin/index">Admin</a>)';
}
}
When I do a var_dump of $user_status, it says "bool(false)" when it should say "1" because that is the default user_status in the database.
I have the login script checking if the user is banned too, and that works perfectly fine:
$check_banned = $db->prepare("SELECT `user_status` FROM `users` WHERE `username` = :username");
$check_banned->bindValue(":username",$_POST['username'],PDO::PARAM_STR);
$check_banned->execute();
$check_banned = $check_banned->fetchColumn();
Upvotes: 0
Views: 117