Beispiel #1
0
 public function register()
 {
     if ($this->isPost()) {
         $email = trim($_POST['email']);
         $password = trim($_POST['password']);
         $password2 = trim($_POST['password_repeat']);
         if ($password != $password2) {
             $this->putErrorMsg('两次密码不一致');
         }
         if (!preg_match('/[0-9a-zA-Z_\\.\\@\\#\\$\\%]{6,18}/', $password)) {
             $this->putErrorMsg('/[0-9a-zA-Z_\\.\\@\\#\\$\\%]{6,18}/');
         }
         if (empty($email)) {
             $this->putErrorMsg('email不能为空');
         } else {
             if (true != Validate::check($email, 'varchar', '1_email')) {
                 $this->putMsg('不是email');
             }
         }
         if ($this->isErrorMsgEmpty()) {
             $userModelDB = new UserModelDB();
             $r = $userModelDB->save($email, sha1($password));
             $uid = $userModelDB->insertId();
             if ($r) {
                 $this->putmsg('注册成功');
                 $um = new UserModel();
                 $succ = $um->setUserCookie(array('email' => $email, 'uid' => $uid));
                 if (!$succ) {
                     $this->putErrorMsg('您居然把cookie关了...');
                 }
             } else {
                 $this->putErrorMsg('注册失败' . $r);
             }
         }
     }
     var_dump($this->getMsg());
     var_dump($this->getErrorMsg());
     $this->setView('msg', $this->getMsg());
     $this->setView('errorMsg', $this->getErrorMsg());
     $this->display('register.html');
 }