checking letter case using php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mang
Forum Newbie
Posts: 8
Joined: Thu Nov 02, 2006 12:43 am

checking letter case using php

Post 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
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post 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.
User avatar
ddragas
Forum Contributor
Posts: 445
Joined: Sun Apr 18, 2004 4:01 pm

Post 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
Post Reply