/
login.php
154 lines (83 loc) · 3.18 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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Login</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<style>
h4 {
color: #3DA4BE;
}
</style>
<body>
<?php
// error_reporting(E_ALL & ~E_DEPRECATED);
// ini_set('display_errors', 'On');
// restore_error_handler ();
?>
<?php
// $connect = mysql_connect('localhost','root','root') or die (mysql_error('Соединение с базой данных неактивно =/'));
// mysql_select_db('users');
$dbh = new PDO('mysql:host=localhost;dbname=project1','root', 'root');
$dbh->exec('SET NAMES utf8');
?>
<?php
if(isset($_POST['enter'])) {
$login_email = $_POST['login_email'];
$email = $_POST['email'];
$psword = md5($_POST['psword']);
# $regdate = $_POST['regdate'];
# $regtime = $_POST['regtime'];
// $query = mysql_query("SELECT * FROM `project1`.`users` WHERE `login` = '$login';");
// $user_data = mysql_fetch_array($query);
$slct = "SELECT * FROM users WHERE `login` = '$login_email' OR `email`= '$login_email';";
$assoc_res = $dbh->query($slct);
$dbh = NULL;
$user_data = $assoc_res->fetch(PDO::FETCH_ASSOC);
if ($user_data['psword'] == $psword) {
echo "<h4>Успех!</h4>";
header('Location: http://localhost/index.php/articles');
}
else {
echo "<h4>Что то не сошлось =|</h4>";
}
}
?>
<div class="logo"></div>
<form method="post" action="login.php">
<div class="login-block">
<h1>Login</h1>
<div id="avatar">
<!-- Выведение аватарки в Ячейку Логина -->
<?php
session_start();
// отображение картинки из базы данных
function displayAvatar() {
$id = $_SESSION['id'];
$dbh = new PDO('mysql:host=localhost;dbname=project1','root', 'root');
$slct = "SELECT * FROM users WHERE `id` = '$id';";
$assoc_res = $dbh->query($slct);
$dbh = NULL;
$row = $assoc_res->fetch(PDO::FETCH_ASSOC);
// $query = mysql_query("SELECT * FROM `project1`.`users` WHERE `id` = '$id';");
// $row = mysql_fetch_assoc($query);
echo '<img height="160" width="150" src="data:image;base64,'.$row['avimg'].' ">';
}
displayAvatar();
// отображение картинки из базы данных
?>
<!-- Выведение аватарки в Ячейку Логина -->
</div>
<br>
<input type="text" value="" placeholder="Login" class="iconname" name="login_email" />
<input type="text" value="" placeholder="E-mail" class="iconname" name="email" />
<input type="password" value="" placeholder="Password" class="lock" name="psword" />
<!-- <input type="hidden" name="regdate" value="<?php echo date ('Y-m-d'); ?>">
<input type="hidden" name="regtime" value="<?php echo date ('H:i'); ?>" >
МОЖНО ли как то дату и время привязать к посещению????? -->
<input class="reg_button" type="submit" name="enter" value="enter">
</div>
</form>
</body>
</html>