This topic is locked

BeforeLogin event strip username characters?

5/5/2010 18:09:04
PHPRunner General questions
F
FunkDaddy author

I don't know why this isn't working for me... I am trying to strip the username anytime it has an "@" symbol in it.
I'm basically making sure that if users accidentally put in a username such as john@gmail.com that the page will pick-up the "john" part and ignore the @ symbol thereafter. I have already taken steps to prevent users from creating accounts with @ symbols in their username, however, because of the nature of my application I know many users will still accidentally put "john@gmail.com" instead of just john. I'm in a way copying what gmail does for login... it doesn't matter whether I enter "albert" or "alebert@gmail.com" to access my account, either way works.
My approach was to place this in the BeforeLogin Event of the login page:
$breakdown = explode("@",$username);

$username = $breakdown[0];
This code is working, as I verified using an echo statement on the page to show me the $username... and in fact it is exploding as instructed to do via PHP, however, PHPRunner seems to be ignoring this new value I assigned to $username, thereby denying my user login.
Can anyone please help?
M

Sergey Kornilov admin 5/5/2010

BeforeLogin event is not designed to modify usernames.
You can try the following though:



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

$breakdown = explode("@",$username);

$sUsername = $breakdown[0];
$strSQL = "select * from <login table name here> where ".AddFieldWrappers($cUserNameField).

"='".db_addslashes($sUsername)."' and ".AddFieldWrappers($cPasswordField). "=".$strPassword;