コード例 #1
0
ファイル: UserController.php プロジェクト: realphp/yii2-admin
 public function actionCreate()
 {
     $model = new YiiUser();
     $model->scenario = 'create';
     $model->created_time = time();
     $model->cnum = $model->createCompanyNum();
     $model->load(Yii::$app->request->post());
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         //            Yii::$app->session->setFlash('success', '发送成功!');
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
コード例 #2
0
 /**
  * @return string|\yii\web\Response 用户注册
  */
 public function actionSignup()
 {
     $model = new YiiUser();
     $data = Yii::$app->request->post();
     //$model->user=$data['user'];
     $model->pwd = md5($data['pwd']);
     //$model->authKey=$data['authKey'];
     //$model->accessKey=$data['accessKey'];
     $model->email = $data['email'];
     //$model->find()->where(['email'=>$data['email']])->one();
     if ($model->find()->where(['email' => $data['email']])->one() || $model->find()->where(['user' => $data['user']])->one()) {
         echo "already exists";
     } else {
         $model->save();
         echo json_encode("sighup success");
     }
 }