-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact.php
81 lines (62 loc) · 1.8 KB
/
contact.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
/**
* User: PC-Maus
* Date: 09.03.2018
* Time: 11:19
*/
session_start();
include_once ('function.php');
$db = db_connect();
$name = $_POST['name'];
$_SESSION['name'] = $name;
$_SESSION['password'] = $_POST['password'];
$password = md5($_POST['password']);
$sql = "SELECT * FROM reg WHERE name = \"$name\"";
$request = $db->query($sql);
$fetch = $request->FetchAll(PDO::FETCH_ASSOC);
if (count($_POST) > 0) {
if(false == $fetch){
echo "<h1>Веддите данные</h1>";
}
foreach ($fetch as $key => $value) {
$user_name = $fetch[$key]['name'];
$user_password = $fetch[$key]["password"];
}
// PDO
if($user_name == 'admin' && $user_password == $password){
$_SESSION['admin'] = true;
header('Location: http://autoriz/admin.php');
exit;
}
if($user_name == $name && $user_password == $password){
$_SESSION['user'] = true;
header('Location: http://autoriz/user.php');
exit;
}
if ($user_name == $name) {
echo "<h1>Имя паравильно введите пароль</h1>";
}else{
echo "<h1>Имя введено не правильно</h1>";
}
if ($user_password == $password) {
echo "<h1>Пароль ввели верно</h1>";
}else{
echo"<h1>Возможно не верно ввели пароль</h1>";
}
}
else {
echo "<h1>Проверьте правильность введеных данных</h1>";
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
</body>
</html>