-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
47 lines (39 loc) · 1.41 KB
/
login.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
<?php
include "configs/main.php";
include $siteUrl . '/configs/db.php';
include $siteUrl . '/parts/header.php';
if (isset($_POST["login"]) && isset($_POST["password"])
&& $_POST["login"] != "" && $_POST["password"] != "" ){
$sql = "SELECT * FROM user WHERE phone LIKE '" . $_POST["login"] ."' AND password LIKE '" . $_POST["password"] . "' ";
$result = ($conn->query($sql));
$kolich_users = mysqli_num_rows($result);
if ($kolich_users == 1) {
$user = mysqli_fetch_assoc($result);
// создаем КУКИ для хранения данных пользователя
setcookie("authorized_user_id", $user["id"], time() + 10000);
// перенаправить на страницу
header("Location: /");
} else {
echo "<h2>Error authorisation</h2>";
}
}
?>
<div class="row">
<form method="POST">
<div class="form-group">
<label>Login</label>
<input class="form-control" type="text" name="login">
<small class="form-text text-muted">Enter phone number</small>
</div>
<div class="form-group">
<label>Password</label>
<input class="form-control" type="password" name="password">
<small class="form-text text-muted">Enter password</small>
</div>
<button type="submit" class="btn btn-secondary">Enter</button>
<a href="register.php" type="button" class="btn btn-secondary">Registration</a>
</form>
</div>
<?php
include $_SERVER['DOCUMENT_ROOT'] . '/parts/footer.php';
?>