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("注册失败!"); } } } ?>