/** * отображение формы логина и проверка данных */ public function login() { if (isset($_SESSION['logged_user'])) { header('Location: /'); } $errors = array(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (!isset($_POST['exampleInputEmail1']) || empty($_POST['exampleInputEmail1'])) { $errors['exampleInputEmail1'] = "This field is required"; } if (!isset($_POST['exampleInputPassword1']) || empty($_POST['exampleInputPassword1'])) { $errors['exampleInputPassword1'] = "This field is required"; } if (!$errors) { $usersModel = new UsersModel(); $status = $usersModel->checUserExist($_POST); if ($status) { $_SESSION['logged_user'] = $status; addNotification('Welcome!'); header('Location: /'); } else { $errors['exampleInputEmail1'] = "Please verify you credentials"; } } } include 'views/login.php'; }