userModel = new UserModel(); $this->view = $view; } public function loginUser() { $erg = array(); $erg = $this->userModel->loginUser($this->sanitize($_POST["username"]), $this->sanitize($_POST["password"]) ); if ($erg["success"] == true) { header("Location: ?controller=Welcome&do=showWelcome"); exit(); } else { $this->view->setDoMethodName("showUserLoginForm"); $this->showUserLoginForm(); } } public function logoutUser() { $this->userModel->logoutUser(); header("Location: ?controller=User&do=showUserLoginForm"); exit(); } public function registerUser() { $erg = array(); $erg = $this->userModel->registerUser($this->sanitize($_POST["username"]), $this->sanitize($_POST["password"]) ); if ($erg["success"] == true) { header("Location: ?controller=User&do=showUserLoginForm"); exit(); } else { $this->view->setDoMethodName("showUserRegisterForm"); $message = $this->sanitize($erg['message']); echo ""; $this->view->setVars([ "errmsg" => $message ]); $this->showUserRegisterForm(); } } public function showUserLoginForm() { } public function showUserRegisterForm() { } function sanitize($data, $flags = ENT_QUOTES, $encoding = 'UTF-8') { return htmlspecialchars((string)$data, $flags, $encoding); } }