This topic is locked

Username in lowercase

5/24/2007 1:19:25 AM
PHPRunner General questions
S
spoilar author

v3.1 218
To prevent users from being unable to log on when using uppercase, I used the code from a previous post. However it is not working. Any idea why?
This is inserted in the Login>BeforeLogin event

function BeforeLogin($username, $password)

{
//********** Convert to Lowercase ************
$username = strtolower($username);

$password = strtolower($password);

return true;
}
Alexey admin 5/24/2007

Hi,
use this code in BeforeLogin event:

function BeforeLogin($username, $password)

{

global $strSQL,$cUserNameField,$strUsername,$cPasswordField,$strPassword;
$strSQL = "select * from users where ".AddFieldWrappers($cUserNameField).

"=".strtolower($strUsername)." and ".AddFieldWrappers($cPasswordField).

"=".strtolower($strPassword);

}


where usersis your actual table name.

S
spoilar author 5/24/2007

Hello Alexey,
I did exactly what you said. Then it would not allow me to log on at all.
I added "return true;" at the end and at least I could log on with the username in lowercase. But I still could not log on if there was any uppercase.
This is what I used first.

function BeforeLogin($username, $password)

{

global $strSQL,$cUserNameField,$strUsername,$cPasswordField,$strPassword;
$strSQL = "select * from ab_user where ".AddFieldWrappers($cUserNameField).

"=".strtolower($strUsername)." and ".AddFieldWrappers($cPasswordField).

"=".strtolower($strPassword);

}

This is what let me log on if I used lowercase as it is in the database.

function BeforeLogin($username, $password)

{

global $strSQL,$cUserNameField,$strUsername,$cPasswordField,$strPassword;
$strSQL = "select * from ab_user where ".AddFieldWrappers($cUserNameField).

"=".strtolower($strUsername)." and ".AddFieldWrappers($cPasswordField).

"=".strtolower($strPassword);

return true;

}


ab_user is the name of my table.

S
spoilar author 5/24/2007

Just to clarify what I am trying to do, I want a user to be able to log on if they type
Username: First.Last@example.com

Password: PASSWORD
when it is actually
username = first.last@example.com

password = password
in the ab_user table.
I could just tell the users that the log in is case sensitive, but it wouldn't be very practical since the users are constantly changing and they are from all over the world. Many of them not speaking english.
So any help would be very much appreciated.

J
Jane 5/25/2007

Hi,
sorry for my fault.

Here is the correct code:

function BeforeLogin($username, $password)

{

global $strSQL,$cUserNameField,$strUsername,$cPasswordField,$strPassword,$sUsername,$sPassword;

$sUsername=strtolower($sUsername);

$sPassword=strtolower($sPassword);

$strSQL = "select * from ab_user where ".AddFieldWrappers($cUserNameField).

"=".strtolower($strUsername)." and ".AddFieldWrappers($cPasswordField).

"=".strtolower($strPassword);

echo $strSQL;

return true;

}

S
spoilar author 5/25/2007

THAT WORKED!
Thank you so much!