-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
47 lines (43 loc) · 1.74 KB
/
index.php
File metadata and controls
47 lines (43 loc) · 1.74 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Voloshin V.A.</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<link rel=”stylesheet” href=”https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css” />
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container-nav">
<div class="logo-nav logo"></div>
</div>
<div class="container">
<div class="row">
<div class="col-12 index">
<?php
if (!isset($_COOKIE['User'])){
?>
<h1>Авторизуйтесь</h1>
<a href="/registration.php">Зарегистрируйтесь</a> или <a href="/login.php">Войдите в систему</a>!
<?php
}else{
$link = mysqli_connect('127.0.0.1', 'root', '123', 'dbCat');
echo "<h1>Посты</h1>";
$sql = "SELECT * FROM posts";
$res = mysqli_query($link, $sql);
if (mysqli_num_rows($res) > 0) {
while ($post = mysqli_fetch_array($res)) {
echo "<a href='/posts.php?id=" . $post["id"] . "'>" . $post['title'] . "</a><br>";
}
} else {
echo "Записей пока нет";
}
}
?>
</div>
</div>
</div>
</body>
</html>