您现在的位置是:首页 > cms教程 > ecshop商城教程ecshop商城教程

ecshop邮箱登录的实现方法

紫翠2025-02-10 18:13:32ecshop商城教程已有3人查阅

导读邮箱登录a.找到function login(){} ,增加一个邮箱判断is_mail() ,b.如果通过,增读取出username ,c.再通过默认的login功能1.需要修改文件include/modules/integrates/integrate

邮箱登录
a.找到function login(){} ,增加一个邮箱判断is_mail() ,
b.如果通过,增读取出username ,
c.再通过默认的login功能
1.需要修改文件include/modules/integrates/integrate.php
原代码 第145行
function login($username, $password, $remember = null)
{
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;
}
}
修改代码
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(is_telephone($username)){
$sql = "select ".$this->field_name." from ".$this->table($this->user_table)." where mobile_phone ='".$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;
}
}
2.include/lib_common.php 增加手机判断格式 第40行
function is_telephone($phone){
$chars = "/^13[0-9]{1}[0-9]{8}$|15[0-9]{1}[0-9]{8}$|18[0-9]{1}[0-9]{8}$/";
if(preg_match($chars, $phone)){
return true;
}else{
return false;
}
}

本文标签:

很赞哦! (0)

暂无内容
暂无内容
暂无内容
暂无内容
留言与评论 (共有 0 条评论)
昵称:
匿名发表 登录账号
         
验证码: