Question

I have login/register system on my website but I hade no idea how to match usernames.

If I have a user named "Vlajko" and he is able to login only if he inputs name "Vlajko" but not "vlajko" or any other combination, how can I prevent registering of a new user named "vlajKO" because it won't match the record "Vlajko" from the database while going through the check I have in php because that column is case sensitive?

So, I have user Vlajko, and a new user is comming and trying to register with name vlajKO (or vlajko). PHP checks with mysqli through the database for the record named vlajKO but it can't find it because it doesn't exist, and Vlajko exists, and users are able to login with the exact name so that column is case sensitive so that system will let user to register with that name and I don't want that.

It's a little bit confusing but I hope you will understand.

Was it helpful?

Solution

SELECT as lowercase,

SELECT COUNT(*) FROM mytable WHERE LOWER(mytable.login) = LOWER('vlajKO');

if it return != from 0 then there is already someone with this name non-case sensituve

OTHER TIPS

Change the column 'name' (or what ever you used) in the database to primary key and it will not be possible to save 2 entries with the same value (not case-senstive).

When your checking existing username during registration, modify your mysql query with condition: WHERE lower(username) = lower(?s) , where ?s - registering username

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top