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
You are not logged in. Please login or register.
PunBB Forums → PunBB 1.2 discussion → 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
Because MySQL does a case insensitive comparison with the default collation
Cheers. 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
No, although that causes issues with registration (you can register usernames where the difference is a change in case).
That, I could live with, if needs be. I'm just unjustifiably pedantic about silly little things like case. 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
Oh, you only need to run one check there, lower works as well as upper.
Apologies for keep asking questions, 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
You don't need to call both lower and upper. You need only call one.
Cheers. I presume that means I've misinterpreted somewhat exactly what the upper/lower do then?
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.
Do I feel such a prat now you've explained it. The penny just never dropped before. Cheers for the explanation.
PunBB Forums → PunBB 1.2 discussion → Lowercased login
Powered by PunBB, supported by Informer Technologies, Inc.