forked from htmlacademy-php1/1622797-yeticave-14
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sign-up.php
37 lines (29 loc) · 956 Bytes
/
sign-up.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
<?php
/**
* @var mysqli $link
*/
require_once __DIR__ . '/init.php';
$user_name = check_session_name();
$categories = get_categories($link);
$errors = [];
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$signup_form = filter_input_array(INPUT_POST, [
'email' => FILTER_SANITIZE_SPECIAL_CHARS,
'password' => FILTER_SANITIZE_SPECIAL_CHARS,
'first_name' => FILTER_SANITIZE_SPECIAL_CHARS,
'contact' => FILTER_SANITIZE_SPECIAL_CHARS
], true);
$errors = validate_signup_form($link, $signup_form);
if (!$errors) {
add_user($link, $signup_form);
header("Location: /login.php");
exit();
}
}
$content = include_template('sign-up.php', ['categories' => $categories, 'errors' => $errors]);
$layout_content = include_template('layout.php', [
'categories' => $categories,
'content' => $content,
'title' => 'Страница регистрации'
]);
print($layout_content);