-
Notifications
You must be signed in to change notification settings - Fork 1
/
login.php
43 lines (36 loc) · 1.04 KB
/
login.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
* @var array $categories
* @var string $userName
* @var array $users
* @var array $formData
* @var mysqli $link
* @var string $pageTitle
*/
require_once __DIR__ . '/bootstrap.php';
$formData = [];
$errors = [];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$formData = filterFormFields($_POST);
$errors = validateLoginForm($link, $formData);
$user = getUserByEmail($link, $formData['email']);
if (empty($errors)) {
$_SESSION['user'] = getUserByEmail($link, $formData['email']);
header('Location: /');
exit();
}
}
$menu = includeTemplate('menu.php', ['categories' => $categories]);
$pageContent = includeTemplate('login-tmp.php', [
'categories' => $categories,
'formData' => $formData,
'errors' => $errors,
]);
$footer = includeTemplate('footer.php', ['menu' => $menu]);
$layoutContent = includeTemplate('layout.php', [
'footer' => $footer,
'menu' => $menu,
'pageContent' => $pageContent,
'pageTitle' => $pageTitle . ' | Вход',
]);
print($layoutContent);