public function actionIndex() { // create instance of app\models\AuthForm $model = new AuthForm(); // Load data to the model for server side validation $model->load(\Yii::$app->request->post()); if ($model->validate()) { print "validated " . $model->username . ' ' . $model->password; } else { print "not validated"; } // push the model instance to the view return $this->render('index', ['model' => $model]); }
public function actionAuth() { $model = new AuthForm(); $error = null; if ($model->load(Yii::$app->request->post()) && $model->validate()) { $login = Html::encode($model->login); $password = md5($model->password); $uc = new UserClass(); if ($uc->login($login, $password)) { return $this->render('account'); } else { $error = 'Неверный логин или пароль, повторите попытку'; } } return $this->render('auth', ['model' => $model, 'error' => $error]); }