Answer the question
In order to leave comments, you need to log in
Yii2 passing empty login?
Hello! I did registration and authorization according to the lesson, but in the end for some reason the username does not pass to me
public function actionSignup(){
if (!Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new SignupForm();
if($model->load(\Yii::$app->request->post()) && $model->validate()){
$user = new User();
$user->username = $model->username;
$user->password = \Yii::$app->security->generatePasswordHash($model->password);
if($user->save()){
return $this->goHome();
}
}
return $this->render('signup', compact('model'));
}
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'username'
The SQL being executed was: INSERT INTO `user` (`id`) VALUES (DEFAULT)
Error Info: Array
(
[0] => 23000
[1] => 1062
[2] => Duplicate entry '' for key 'username'
)
↵
Caused by: PDOException
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'username'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question