Exemplo n.º 1
0
 public function signUp()
 {
     //判断参数是否合法
     $email = $_POST['em'];
     $passwd = $_POST['pass'];
     $email = filter_var($email, FILTER_SANITIZE_EMAIL);
     $regex = '/[^A-Za-z0-9]/';
     if (!filter_var($email, FILTER_VALIDATE_EMAIL) || preg_match($regex, $passwd) || strlen($passwd) < 6) {
         $result['errNum'] = '0006';
         $result['errMsg'] = errorcode::$error[$result['errNum']];
         $this->renderJson($result);
     }
     //写入mysql,并分配一个自增的uid
     $passwd = md5($passwd);
     $userModel = new userModel();
     $ret = $userModel->insert($email, $passwd);
     if (!$ret) {
         $result['errNum'] = '0002';
         $result['errMsg'] = errorcode::$error[$result['errNum']];
         $this->renderJson($result);
     }
     $result['errNum'] = '0000';
     $result['errMsg'] = errorcode::$error[$result['errNum']];
     $this->renderJson($result);
 }