/** * Creates a new Staff model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Staff(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->staff_id]); } else { return $this->render('create', ['model' => $model]); } }
public function actionSignup() { $formalemail = $_POST['id']; $name = $_POST['name']; $email = $_POST['email']; $pass = $_POST['pass']; $staff = new Staff(); $staff->formalemail = $formalemail; $staff->name = $name; $staff->email = $email; $staff->password = $pass; $status = array(); $checkExists = Staff::find()->where(['formalemail' => $formalemail])->one(); if ($checkExists == NULL) { if ($staff->save()) { $status["status"] = "ok"; $status["formalemail"] = $formalemail; $status["name"] = $name; $status["email"] = $email; } else { $status["status"] = "failed"; } } else { $status["status"] = "failed"; } return json_encode($status); }