Forum Moderators: coopster

Message Too Old, No Replies

User login help

username duplication

         

StoutFiles

2:01 am on Oct 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When I have a user sign up, I want the username to not be different if someone else capitalizes a letter.

For example, John sets up a username with the username John.

I want it so that no one else can be john, jOHN, JoHn, etc. Also, when John logs in, I want him to be able to type in john, jOHN, etc. and be able to log in.

When he does log in, it will display the username how he originally set it up, John. Info is stored in a MySQL database. Any ideas?

Anyango

6:15 am on Oct 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What you can do is to save the username exactly as they entered, in your MySQL database. So save John if they said John or save michAel if they said michAel or save kim if they said kim.

Then in your login script when you compare the username they entered into your form, with your MySQL table you can use lower case on both , just for comparison so like

$username=mysql_real_escape_string($_POST['username']);
$password=mysql_real_escape_string($_POST['password']);
$username=strtolower($username);

$sql="SELECT * FROM yourTable where LOWER(username)='$username' and password='$password'";

so this way they will be able to enter their username in any case and still be able to login and yet when they are logged in it will be displayed in the original case as they entered.

Similarly on your add user script you can check mysql for same existing username with strtolower() and LOWER()

Hope it helps

StoutFiles

7:04 am on Oct 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think that should work perfectly. Thanks for your help.