-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.php
More file actions
68 lines (55 loc) · 1.66 KB
/
Copy pathmain.php
File metadata and controls
68 lines (55 loc) · 1.66 KB
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
<?php
/**
* Created by PhpStorm.
* User: maha
* Date: 19.08.17
* Time: 12:37
*/
include_once 'DataBase.php';
require_once 'login.php';
$bd = new DataBase($hn, $un, $pw, $db);
/*
* form
*/
echo <<<_END
<form enctype="multipart/form-data" action="" method="POST" id='form1'>
<pre>
<input type="text" placeholder='Логин/ваша почта' name="login" required="required">
<input type="password" placeholder='Пароль' name="password" required="required">
<input type="submit" value="Вход" name="enter"/>
</pre>
</form>
<form enctype="multipart/form-data" action="" method="POST" id='form2'>
<pre>
<input type="submit" value="Регистрация" name="registration" />
</pre>
</form>
_END;
$bd->start_session();
if (isset($_SESSION['login'])){
echo <<<_END
<a href="authorisation/cabinet.php">Личный кабинет</a>
_END;
}
if (isset($_POST['enter'])){
if (isset($_POST['login']) && isset($_POST['password'])){
if ($bd->is_user($_POST['login'], $_POST['password'])){
$bd->add_session($_POST['login'], $_POST['password']);
if ($_SERVER['PHP_SELF']==='/index.php')
header("Location: authorisation/cabinet.php");
else
header("Location: cabinet.php");
} else {
echo "неверный логин или пароль";
}
} else {
echo "не ввели логин или пароль!";
}
}
if (isset($_POST['registration'])){
if ($_SERVER['PHP_SELF']==='/index.php')
header("Location: authorisation/registration.php");
else
header("Location: registration.php");
}
?>