-
Notifications
You must be signed in to change notification settings - Fork 0
/
log_in.php
59 lines (59 loc) · 2.41 KB
/
log_in.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
<!DOCTYPE html>
<html lang="ru">
<head>
<title>Страница входа</title>
<meta charset='utf-8'>
<link rel="stylesheet" href="../Style/gallery_stylesheet.css">
</head>
<body>
<?php
require_once("connect_db.php");
date_default_timezone_set("Europe/Moscow");
if (!isset($_REQUEST['Action']))
{ ?>
<form action = "<?=$_SERVER['SCRIPT_NAME']?>">
<h2>Вход:</h2>
<p>Логин: <input type="text" name="login" value=""></p>
<p>Пароль: <input type="password" name="password" value=""></p>
<input type ="submit" name="Action" value="Log in">
<input type ="submit" name="Action" value="Register">
</form>
<?php
} else
{
switch($_REQUEST['Action'])
{
case 'Log in':
$username = $_REQUEST['login'];
$password = $_REQUEST['password'];
$query = "SELECT admin_flag FROM users WHERE username='$username' AND passw='$password'";
$buff = $pdo->query($query);
$buff = $buff->fetchAll(PDO::FETCH_ASSOC);
if($buff)
{
$buff = $buff['0'];
$value = $buff['admin_flag'];
setcookie('admin_flag', $value);
setcookie('username', $username);
header("Location: $dir/galleries_list.php");
}
else
die("Ошибка, такого пользователя не существует.");
break;
case 'Register':?> <!-- Просто задел на будущее, пока только внешний вид-->
<form action = "<?=$_SERVER['SCRIPT_NAME']?>">
Регистрация:<br />
e-mail: <input type="text" name="login" value=""><br />
Логин: <input type="text" name="login" value=""><br />
Пароль: <input type="password" name="password" value=""><br />
Повторите пароль: <input type="password" name="repeat_password" value=""><br />
<input type ="submit" name="Action" value="Register">
<input type ="submit" name="Action" value="Back">
</form>
<?php
break;
}
}
?>
</body>
</html>