When a user is banned it echo's the wrong notice out

前端 未结 2 1696
栀梦
栀梦 2021-01-27 07:43

When the user is banned it should echo out the banned echo but instead it echo\'s out the Failed login echo, Somewhere along the line I\'ve messed something up if someone could

2条回答
  •  执念已碎
    2021-01-27 08:31

    place this line outside if block

    $SQL = $odb->prepare("SELECT `status` FROM `users` WHERE `username` = :username");
            $SQL->execute(array(':username' => $username));
            $status = $SQL->fetchColumn(0);
    

    and in else part whaich says login failed do this

    else // else for login failed
    {
    
    if($status == 1)
            {
            $SQL = $odb->prepare("SELECT `reason` FROM `bans` WHERE `username` = :username");
            $SQL->execute(array(':username' => $username));
            $ban = $SQL->fetchColumn(0);
    echo '
    '; die('You are banned. Reason: ' . htmlspecialchars($ban)); } echo '
    '; }

    you also tried to print that banned for valid users too

提交回复
热议问题