A5下载 - 努力做内容最丰富最安全的下载站!

A5站长下载站

当前位置:A5下载 > 源码技巧 > Ecshop > 让ecshop用户名和email都可以登陆!

让ecshop用户名和email都可以登陆!

时间:2015-10-15 16:36作者:fang人气:96

让ecshop用户名和email都可以登陆!

在最近的几次开发案例中, 客户经常提到使自己的网站能够用email登陆.

确实,自2005年,web2.0兴起以来,越来越多的网站,尤其是新兴网站,大多是用email登陆的.

用email登陆,好处很明显.

1:可以促使用户填写真实的email.

2:不易忘记.

下面的改动,可以使ecshop用email,用户名都可以完成登陆.

改动版本: ecshop 2.7.0

改动程序: /includes/modules/integrates/integrate.php

改动代码:145--162行的用户登陆函数.如下

function login($username, $password)

{

if ($this->check_user($username, $password) > 0)

{

if ($this->need_sync)

{

$this->sync($username,$password);

}

$this->set_session($username);

$this->set_cookie($username);

return true;

}

else

{

return false;

}

}

改为:

function login($username, $password)

{

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;

//echo $sql;exit;

}

if ($this->check_user($username, $password) > 0)

{

if ($this->need_sync)

{

$this->sync($username,$password);

}

$this->set_session($username);

$this->set_cookie($username);

return true;

}

else

{

return false;

}

}

是否有其他改动方法:有,但经过几次试验,这种方法目前是最平滑的.

标签ecshop,户名,email,都可以,登陆,ecshop

相关下载

查看所有评论+

网友评论

网友
您的评论需要经过审核才能显示

公众号