validation für registration

This commit is contained in:
Illia Hromovoi 2025-07-03 11:52:12 +02:00
parent 625cf0f30e
commit 582db52aa6

View File

@ -31,11 +31,19 @@ class UserController{
} }
public function showUserRegisterForm(){ public function showUserRegisterForm(){
if (!isset($this->errors)) {
$this->errors = [];
}
if (!isset($this->validData)) {
$this->validData = [];
}
$this->view->setVars([ $this->view->setVars([
'labels' => $this->labels, 'labels' => $this->labels,
'errors' => $this->errors, 'errors' => $this->errors,
'validData' => $this->validData 'validData' => $this->validData
]); ]);
} }
public function showUserRegisterConfirmation(){ public function showUserRegisterConfirmation(){
@ -98,8 +106,15 @@ class UserController{
} }
public function register(){ public function register(){
$this->db->createUser($_POST); $this->validateForm();
$this->login();
if(count($this->errors) > 0){
$this->view->setDoMethodName("showUserRegisterForm");
$this->showUserRegisterForm();
} else{
$this->db->createUser($_POST);
$this->login();
}
} }
public function login(){ public function login(){