-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
62 lines (47 loc) · 1.77 KB
/
index.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
require "connect.php";
$mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : false;
if ($_SERVER['REQUEST_METHOD'] === 'POST'){
//Авторизация
if($mode === 'users') {
$email = trim($_REQUEST['email']);
$user = $mysqli->query("SELECT email, password FROM users where email = '$email' limit 1");
$user = mysqli_fetch_array($user, MYSQLI_ASSOC);
if ($user) {
if (password_verify(trim($_REQUEST['password']), $user['password'])) {
$customers = $mysqli->query("SELECT * FROM users");
while ($result = mysqli_fetch_array($customers, MYSQLI_ASSOC)){
$users[] = $result;
}
$feed = $mysqli->query("SELECT * FROM feedback");
while ($result = mysqli_fetch_array($feed, MYSQLI_ASSOC)){
$feeds[] = $result;
}
require 'users_list.html';
} else {
require 'index.html';
}
}
exit();
}
//Registration
$first_name = trim($_REQUEST['first_name']);
$last_name = trim($_REQUEST['last_name']);
$gender = trim($_REQUEST['gender']);
$email = trim($_REQUEST['email']);
$pass = password_hash(trim($_REQUEST['password']), PASSWORD_BCRYPT);
$mysqli->query("INSERT INTO users (first_name, last_name, gender, email, password) VALUES ('$first_name','$last_name','$gender','$email','$pass')");
}
//Вывод пользвателей
/*$customers = $mysqli->query("SELECT * FROM users");
while ($result = mysqli_fetch_array($customers, MYSQLI_ASSOC)){
$users[] = $result;
}*/
if ($mode === 'auth'){
require 'auth.html';
}else{
require 'index.html';
}
/*require 'index.html';*/
/*require 'users_list.html';*/
exit();