public function Login() { if (isset($_SESSION['is_logged'])) { header("Location: " . __MAIN_URL__ . __HOME_DIRECTORY__); exit; } if (isset($_POST['loginButton'])) { $username = $_POST['username']; $pass = $_POST['password']; $userModel = new UsersModels(); try { $userModel->login($username, $pass); } catch (\Exception $e) { View::$viewBag['errors'][] = $e->getMessage(); } } $categoriesModel = new CategoriesModel(); $categories = $categoriesModel->getAllCategories(); $model["categories"] = $categories; return new View($model); }