Now many of the mainstream e-commerceThe website is directly using email asMember account, the advantage is to saveUsers both want a user name, but also fill the mailbox, e-mail e-commerce website importance not to mention, so use email as a member of the unique logo is very reasonable practice, this paper gives the ecshop to achieveFunction of the method, the principle isWhen registering the value of the email form to return to the username, and remove the registration username JSValidation, and then inLogin to implement username and email can be logged in, the advantage is that the realization of ecshop with email registration login function, and do not change the EcshopDatabase, andBackstage function, in fact, there is no change in nature, the membership account is still there, the mailbox is there, but we force the member account equal to the email account.
first modify the registration section
------------------------------------------------------------------------------------------------------- ------------------
1,THEMES/****/USER_PASSPORT.DWT the form entered by the member name, remove it
2,js/user.js Find the function register () andCodeDelete
if (Username.length = = 0)
{
msg + = Username_empty + ' \ n ';
}
else if (Username.match (/^\s*$|^c:\\con\\con$|[ %,\ ' \*\ "\s\t\<\>\&\\]/))
{
msg + = Username_invalid + ' \ n ';
}
else if (Username.length < 3)
{
msg + = Username_shorter + ' \ n ';
}
3,user.php Find ElseIf ($action = = ' Act_register ') put the following code
$username = isset ($_post[' username ')? Trim ($_post[' username '): ";
Switch
$username = isset ($_post[' email ')? Trim ($_post[' email '): ';
Second, you can log in by using email login
------------------------------------------------------------------------------------------------------- ------------------
1,includes/modules/integrates/integrate.php Find function login and change the entire function to the following code
function login ($username, $password, $remember = null)
{
if (Is_email ($username))
{
$sql = "Select". $this->field_name. "from". $this->table ($this->user_table). "Where". $this->field_email. " = ' ". $username." ' ";
$username = $this->db->getone ($sql);
if (! $username) return false;
}
if ($this->check_user ($username, $password) > 0)
{
if ($this->need_sync)
{
$this->sync ($username, $password);
}
$this->set_session ($username);
$this->set_cookie ($username, $remember);
return true;
}
Else
{
return false;
}
}
Modify Ecshop registration only need email, and use email as account