at the moment, i check the username and passwort of a HTML form like this on my database:
$exc = $dbh->prepare("SELECT id, cid, fullname FROM user WHERE username LIKE :username AND password LIKE :password");
I need to check both CASE SENSITIVE when executing the query.
Database data:
username: louis
password: goal43
Form data:
username: LOUIS
password: GOAL43
returns true - how do i fix this ?
$exc = $dbh->prepare("SELECT id, cid, fullname FROM user WHERE BINARY username LIKE :username AND BINARY password LIKE :password");
I hope it helps you. The link I've given to you
You have written query in prepare. Next step to assign parameters to :username
and :password
parameter you can do the by bindParam()
. Which is given below.
$stmt = $dbh->prepare("SELECT id, cid, fullname FROM user WHERE username = :username AND password = :password");
$stmt->bindParam(':username ', $username);
$stmt->bindParam(':password', $password);
$stmt->execute();
just use =
instead of LIKE
LIKE
is case-insensitive
This question is already asked and contains answer , you can see this link there are very good answers for your query Compare string with case sensitive data