-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.php
33 lines (27 loc) · 984 Bytes
/
auth.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
<?php
require_once('init.php');
$errors = [];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$errors['email'] = is_filled('email');
if (!is_filled('email')) {
$errors['email'] = check_email_validity($connect, $_POST['email']);
}
$errors['password'] = is_filled('password');
if (empty($errors['email']) && check_password($connect, $_POST['email'], $_POST['password'])) {
$_SESSION['user_id'] = get_user_id($connect, $_POST['email']);
header('Location: /index.php');
exit();
} elseif (!is_filled('password')) {
$errors['password'] = "Вы ввели неверный email/пароль";
}
};
$page_content_data = [
'errors' => $errors
];
$page_content = include_template('auth.php', $page_content_data);
$layout_content_data = [
'page_content' => $page_content,
'page_name' => 'Авторизация'
];
$layout_content = include_template('layout.php', $layout_content_data);
print($layout_content);