PDA

View Full Version : LowerCase


Goofy12
12-08-2007, 09:30 AM
Hey I made a script to check the username + password
most important line is:
$result = mysql_fetch_array( mysql_query("SELECT * FROM `vb_user` WHERE username='$name' AND password='$pass'",$db) );
but there is one problem, if I check:

user:Username
pass:password
it will work

user:username
pass:password
it wont work.

it depends on how the user registered... if he registered with a uppercase it wont work if i check with lowercase, and if he registered with a lowercase it wont work if I check with uppercase.

Opserty
12-08-2007, 09:42 AM
I presume vb_user is the vBulletin User table correct?

If so your query won't return no matches because you will first have to hash the password so you can compare them. Here is a quick outline of what you need to do:

Connect to the Database
Fetch the Username, Password and SALT
Hash the input password and then hash it again with the salt.
Compare the input password with the Password you fetch from the database
Then do whatever you need to depending on the result.

With regards to your actual question, I don't think Passwords are case sensitive however I'm not too sure about Usernames but I think they are case-sensitve too.

Marco van Herwaarden
12-08-2007, 09:42 AM
There are a few solutions to this:

- Force both to lowercase
- Use LIKE instead of = (WHERE username LIKE '$name')

Edit: In contrary to the previous post, passwords are case-sensitive (the stored hash not really case-sensitive), usernames can be handle case-insensitive.