예제 #1
0
 public function actionRegister()
 {
     if (!empty(Yii::$app->session->get(FVariable::$session_userId_str))) {
         return $this->goHome();
     }
     $UserRegisterForm = new UserRegisterForm();
     $req = Yii::$app->request;
     if (!$UserRegisterForm->load($req->post()) || !$UserRegisterForm->validate()) {
         return $this->render(FVariable::$siteRegister_view, ['UserRegisterForm' => $UserRegisterForm]);
     }
     $UserModel = new User();
     $mobile = $UserRegisterForm->mobile;
     $password = md5($UserRegisterForm->password);
     $salt = '123456789';
     $UserInsert = $UserModel->RegisterNewUser($mobile, $password, $salt);
     $userId = Yii::$app->db->getLastInsertID();
     if ($userId) {
         Yii::$app->session->set(FVariable::$session_userId_str, $userId);
         return $this->redirect(FVariable::$userVipcenter_view);
     }
     return $this->render(FVariable::$siteRegister_view, ['UserRegisterForm' => $UserRegisterForm]);
 }