Modify Ecshop registration only need email, and use email as account

Source: Internet
Author: User
Tags email account

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.