/** * Creates a new User model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Member(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { if ($model->save()) { Yii::$app->session->setFlash('success', "新增完成"); return $this->redirect(['update', 'id' => $model->id]); } } return $this->render('create', ['model' => $model]); }
public function actionRegister() { if (!Yii::$app->user->isGuest) { Yii::$app->getSession()->setFlash('alert', "登入完成"); return $this->redirect(["/"]); } Yii::$app->tool->setPageMetaData("加入會員"); $this->subTitle = "加入會員"; $model = new Member(["scenario" => "insert"]); if ($model->load(\Yii::$app->request->post())) { $model->status = 1; $email = $model->username; $model->email = $email; $model->social_type = "email"; if ($model->save()) { //發mail $result = Yii::$app->tool->sendUserEmailCheckCode($model, EmailCheckCodes::TYPE_REGIST); if (!$result) { throw new \yii\web\HttpException(400, "Email發送失敗", $this->errorLayout); } $maskMail = Yii::$app->tool->mask_email($model->username); Yii::$app->getSession()->setFlash('alert', "我們將發送一封Email到您的信箱 {$maskMail}, 請依照信中指示進行驗證"); //return $this->render("@front/views/topReload"); return $this->goHome(); } } $model->password = null; $model->chkpassword = null; return $this->render('register', array('model' => $model)); }