Ive been working with PHP/MySQL for around a year now, never had this problem before.
Im working on an online text game type thing (yeah, I know, not original but im just brushing up my skills a bit.), for the login I use this query:
PHP Code:
$sql = "SELECT `username`,`email`,`password`
FROM `tbl_members`
WHERE `username = '".$username."'";
Works fine! After that I do my query and checks etc. then set my session variables to exactly the specified username and a SHA1 of the password. If my account is "AxE", it logs in fine with "Axe", "axe", "AXE" etc.
But, here comes the strange part. In my header script for the game area (as in, a script that is included right at the top of each page) I do:
PHP Code:
$username = addslashes($_SESSION['username']);
$password = $_SESSION['password']; //This is in SHA1 encryption, just like in the database.
$sql = "SELECT *
FROM `tbl_members`
WHERE `username` = '".$username."'";
Now, if my account name is "AxE", and I logged in with "AxE", works fine! No problems. But. Always a but. But, If I login with the username "Axe" or "axe", it gets past the login no problem, then, gets to the game area and tells me that my username is incorrect. I did a print_r($_SESSION) in my game headers, got the SHA1 of the password, checked it against the SHA1 of the password in the database, its the same, so that cant be the problem. I get my username, check it against the username in the database and its the same, except for the case.
Does anyone know why my queries are being picky suddenly? Is there anyway to do case sensitive quries? If so, ill just make the login case sensitive.
Thanks,
Your friendly neighbour-hood bashing tool, AxE.