基于TP5正式版的CMS云商城,代码开源

浏览:3085 发布日期:2016/11/14 分类:技术分享
基于tp5.0取回密码的一种写法    /**
     * 取回密码方法
     * 
     */
    public function getPassword()
    {
        if(Request::instance()->isPost()) {
            // 接收post数据
            $mobile            = input('post.mobile');//手机号
            $password          = input('post.password');//密码
            $repassword        = input('post.repassword');//密码
            $code              = input('post.code');
            
            //校验验证码
            $res = $this->checkcode($code,$mobile);
            if($res==true) {
                // 验证手机号是否存在
                $userInfo = Db::name('Users')->where('mobile',$mobile)->find();
                if(!($userInfo['mobile'])) {
                    return $this->error('手机号不存在');
                }
                // 验证两个密码
                if($password != $repassword){
                    return $this->error('两次输入密码不一样');
                }
                // 重置密码
                $newpassword = minishop_md5($password,$userInfo['salt']);
                $result = Db::name('Users')->where('mobile',$mobile)->update(['password'=>$newpassword]);
                if($result) {
                    return $this->success('修改成功!',url('index/base/login'));
                } else {
                    return $this->error('修改失败');
                }
            } else {
                return $this->error('验证码错误');
            }         

        } else {
            return $this->themeFetch('get_password');
        }
        
    }
源码索取QQ群号 :588401996 或登录小微云商官网:http://w.yunshang.shop
最佳答案
评论( 相关
后面还有条评论,点击查看>>