Page 1 of 1

checking letter case using php

Posted: Tue Dec 05, 2006 6:21 am
by mang
How should we match exact letters means(lowercase==lowercase)or(UPPERCASE==UPPERCASE) or(lowercaseUPPERCASE==lowercaseUPPERCASE) while checking for password
for eg. abc=ABC(must not be allowed) abc=aBc(must not be allowed) only abc=abc must be allowed
i want to match the words by cases
but in my site if user pswd is abc and he enter ABC he can easily enter to his control panel
So plz help me in this regard
I m using PHP
Thanking you in advance

Posted: Tue Dec 05, 2006 6:31 am
by impulse()
You could convert all submitted data to lowercase or uppercase.

Code: Select all

$password = strtolower($_POST["passwordbox"]));
It would make sense to convert their password to lower case when they first created a password or else you'll end up with users being unable to login.

Posted: Tue Dec 05, 2006 7:08 am
by ddragas
try using http://hr.php.net/manual/en/function.md5.php when inserting passwords into database. In login form also convert posted value into md5 and then compare it from db

result of hash md5 is not the same for 'password' and 'PASSWORD', and security of braking the users password is more secure.

eg:

Code: Select all

$username=$_POST['username'];
$password=md5($_POST['password']);

$result = mysql_query("
select username, password 
from mytable 
where username = '$username'
and password='$pasword'
 ") or die (mysql_error());
hope I've helped you

regards ddragas