pdo bindParam case sensitive

只愿长相守 提交于 2020-01-06 12:15:10

问题


I want to check if the password is correct (Case sensitive). Currently, I'm using PDO, something like this:

$sql = 'select * from User
        WHERE Email = :user and Password = :pass AND idRole = :role AND idState_User = :state';

    $stat = $this->_db->prepare($sql);
    $stat->bindParam(':user', $user, PDO::PARAM_STR);    
    $stat->bindParam(':pass', $password, PDO::PARAM_STR);  
    $stat->bindParam(':state', $idState_User, PDO::PARAM_INT);  
    $stat->bindParam(':role', $idRole, PDO::PARAM_INT);          
    $stat->execute();

I would like :pass to be case sensitive because if the password is "paSs1234", I can logged in with PASS1234, pass1234 or paSs1234. How can I do to make this case sensitive? Thanks in advance.


回答1:


$sql = 'select * from User
        WHERE Email = :user 
          AND BINARY `Password` = :pass 
          AND idRole = :role
          AND idState_User = :state';


来源:https://stackoverflow.com/questions/24142512/pdo-bindparam-case-sensitive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!