This repository was archived by the owner on Jul 5, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
68 lines (58 loc) · 1.51 KB
/
Copy pathindex.php
File metadata and controls
68 lines (58 loc) · 1.51 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
require_once 'connect.php';
$pageTitle = 'Гостевая книга с использованием базы данных MySQL';
echo <<<s
<!DOCTYPE html>
<html>
<head>
<title>$pageTitle</title>
<meta http-equiv="Content-Language" content="ru">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<h1>$pageTitle</h1>
s;
try {
$sql = 'SELECT * FROM posts ORDER BY date_added DESC';
$result = $DB->query($sql);
$bookRecords = '';
if (!$result) {
echo "<pre>MySQL error:<br>";
echo "Code: {$DB->errno}<br>";
echo "Error:<br>";
print_r($DB->error);
echo "</pre>";
} else {
while ($row = $result->fetch_assoc()) {
$bookRecords .= <<<s
<tr>
<td>{$row['id']}</td>
<td>{$row['username']}</td>
<td>{$row['message']}</td>
<td>{$row['date_added']}</td>
</tr>
s;
}
}
echo <<<s
[<a href="/addMessageForm.php">добавить запись</a>] [<a href="/info.php">phpinfo</a>]
<br><br>
<table border="1" style="border-collapse: collapse;" cellpadding="25">
<tr>
<td>№</td>
<td>Пользователь</td>
<td>Сообщение</td>
<td>Добавлен</td>
</tr>
$bookRecords
</table>
s;
} catch (Exception $e) {
echo "<pre>Exception:<br>";
var_dump($e);
echo "</pre>";
}
echo <<<s
</body>
</html>
s;