1

Topic: Lowercased login

Just out of curiosity, why is the login username lowercased for the login check for every db type other than Mysql/Mysqli?


Cheers,

Matt

Re: Lowercased login

Because MySQL does a case insensitive comparison with the default collation smile

3

Re: Lowercased login

Cheers. smile So actually removing the LOWER statement from that string won't cause any problems, if one is wanting to be stringent with regards to username case?


Thanks,

Matt

Re: Lowercased login

No, although that causes issues with registration (you can register usernames where the difference is a change in case).

5

Re: Lowercased login

That, I could live with, if needs be. I'm just unjustifiably pedantic about silly little things like case. big_smile On that note about registering, however, another question, if I may? Would replicating the username check in register.php with LOWER as well as UPPER, (running the query twice, as it were), stop that scenario arising? A double lookup there would, I assume, be negligible due to that section not being accessed too frequently?


Thanks again,

Matt

Re: Lowercased login

Oh, you only need to run one check there, lower works as well as upper.

7

Re: Lowercased login

Apologies for keep asking questions, smile but SQL not being my strongpoint and such. Would that lookup need doing as such, in that case:

$result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE UPPER(username)=UPPER(\''.$db->escape($username).'\') OR UPPER(username)=UPPER(\''.$db->escape(preg_replace('/[^\w]/', '', $username)).'\') OR LOWER(username)=LOWER(\''.$db->escape($username).'\') OR LOWER(username)=LOWER(\''.$db->escape(preg_replace('/[^\w]/', '', $username)).'\')') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());

or is there a shorthand method, i.e: UPPER/LOWER for that query?


Thanks ever so much once again,

Matt

Re: Lowercased login

You don't need to call both lower and upper. You need only call one.

9

Re: Lowercased login

Cheers. smile I presume that means I've misinterpreted somewhat exactly what the upper/lower do then? big_smile

Re: Lowercased login

Upper converts characters to upper case. Lower converts them to lower case. If you make both sides upper or both sides lower, you've done the same thing, you've made a case insensitive comparison.

11

Re: Lowercased login

Do I feel such a prat now you've explained it. The penny just never dropped before. big_smile Cheers for the explanation.