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

前端 未结 2 1671
栀梦
栀梦 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

    I think it must be

    if ($status[0] == 1) {
    // code
    }
    
    0 讨论(0)
  • 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 '<center><div class="alert alert-icon alert-danger alert-dismissible fade in" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><i class="mdi mdi-check-all"></i>You are banned for Reason...</div></center>';        
            die('<span style="color:red;">You are banned. Reason:</span> ' . htmlspecialchars($ban)); 
            }  
    
                      echo '<center><div class="alert alert-icon alert-danger alert-dismissible fade in" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><i class="mdi mdi-check-all"></i>Login Failed!!</div></center>';
                    }
    

    you also tried to print that banned for valid users too

    0 讨论(0)
提交回复
热议问题