Reputation: 1156
Basically i feel like the problem is simple. but cant find any fix for it.
In a login form, i use php to query my database which on its side check the passed username and password by selecting from the database table any row that has that 2 values.
What seems to be the problem is when i login for ex.
user: mm
pass: oo
that works. and that is right as they are on the db table.
but now if i use
user: MM
pass: oo
still works?? which should not. As my db has only user as 'mm' not 'MM'. I need it to distinguish between upper and lower because in other rows i have mix of upper an lower letters
Upvotes: 2
Views: 296
Reputation: 415
You can update the table using the query:
ALTER TABLE `your_table` CHARSET=latin1 COLLATE=latin1_general_cs;
Where it says latin1_general_cs
, the cs
specifies that it is case sensitive. If you ever desire it not to be case sensitive in the future you can just use this query:
ALTER TABLE `your_table` CHARSET=latin1 COLLATE=latin1_general_ci;
the ci
spcifies that it is case insensitive.
Upvotes: 1
Reputation: 57322
you need to use case sensitive encoding
From 10.1.2. Character Sets and Collations in MySQL
There is a convention for collation names: They start with the name of the character set with which they are associated, they usually include a language name, and they end with _ci (case insensitive), _cs (case sensitive), or _bin (binary).
so use case sensitive like utf8_general_cs
or latin1_general_cs
Upvotes: 1
Reputation: 26124
You'll have to change the collation/encoding of the column from a "case-insensitive" encoding to a case-sensitive one, such as utf8_general_cs
or latin1_general_cs
Upvotes: 5