| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace app\admin\controller;
- use cmf\controller\HomeBaseController;
- use think\Db;
- class MemberController extends HomeBaseController{
- public function register(){
- return $this->fetch(":register");
- }
- public function doRegister(){
- $param = $this->request->param();
-
- $captcha = $this->request->param('captcha');
- if (empty($captcha)) {
- $this->error(lang('CAPTCHA_REQUIRED'));
- }
- //验证码
- if (!cmf_captcha_check($captcha)) {
- $this->error(lang('CAPTCHA_NOT_RIGHT'));
- }
- $name = $this->request->param("username");
- if (empty($name)) {
- $this->error(lang('USERNAME_OR_EMAIL_EMPTY'));
- }
- $pass = $this->request->param("password");
- if (empty($pass)) {
- $this->error(lang('PASSWORD_REQUIRED'));
- }
- if($param['password']!=$param['password1']){
- $this->error('密码不匹配');
- }
- $result = Db::name('user')->where('user_login',$name)->find();
- if (!empty($result)) {
- $this->error('用户名重复');
- }
- $data['user_pass'] = cmf_password($param['password']);
- $data['user_type'] = 1;
- $data['user_login'] = $param['username'];
- $data['create_time'] = time();
- $data['user_type'] = 3;
-
- $result = DB::name('user')->insertGetId($data);
- if ($result !== false) {
-
- Db::name('RoleUser')->insert(["role_id" => 2, "user_id" => $result]);
-
- $this->success("注册成功!", url("admin/public/login"));
- } else {
- $this->error("注册失败!");
- }
- }
- }
- ?>
|