Click here to Skip to main content
15,922,427 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
In this case i've created "logins" table:

+--------+--------------+---------+-----+
|ID_LOGIN| USERNAME     | PASSWORD      |
+--------+--------------+---------+-----+
| 1      | admin        | admin         | 
+--------+--------------+---------------+
| 2      | MaxiKIng1991 | #MaxiKIng1991$|
+--------+--------------+---------------+


I'm going to select all where username and password is specified. But i'd like pay attention to uppercase and lowercase letters. So please take a look. First i selected first login (username and password).

SELECT * FROM `logins` WHERE USERNAME = "AdMin" AND PASSWORD = "AdMin";


When i wrote this query it shows like this:

+--------+--------------+---------+-----+
|ID_LOGIN| USERNAME     | PASSWORD      |
+--------+--------------+---------+-----+
| 1      | admin        | admin         | 
+--------+--------------+---------------+


But in my opinion it shouldn't show the result. I noticed that sql query checks how many strings are in every column name. When i 1 letter too much or too less then shows nothing.

In that second query case:

SELECT * FROM `logins` WHERE USERNAME = "Maxiking1991" AND PASSWORD = "#maxiking1991$";

Then show below result:

SQL
+--------+--------------+---------+-----+
|ID_LOGIN| USERNAME     | PASSWORD      |
+--------+--------------+---------+-----+
| 2      |MaxiKIng1991  |#MaxiKIng1991$ | 
+--------+--------------+---------------+


But it shouldn't show that too.

Is that possible to pay attention to lowercase and uppercase letters in values in that mysql queries? any ideas? I have difficulty to search any solution on it. Thx for any help and advice.

What I have tried:

I've tried with that queries which i described in that problem:

SELECT * FROM `logins` WHERE USERNAME = "AdMin" AND PASSWORD = "AdMin";


SELECT * FROM `logins` WHERE USERNAME = "Maxiking1991" AND PASSWORD = "#maxiking1991$";


But they didn't work.
Posted
Updated 14-Jul-19 22:01pm
Comments
Richard MacCutchan 25-Apr-19 3:54am    
Storing passwords in clear text is asking for trouble. And in the EU it can lead your company to unlimited fines for breach of GDPR.

1 solution

When you create a database, you specify the collation. The default collation is not case sensitive. You need to make that decision for your whole database, or pull back values and check case in code.

It's generally a bad idea to roll your own identity when frameworks like ASP.NET Identity exist
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900