-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathview_post.php
48 lines (40 loc) · 1 KB
/
view_post.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
<?php
session_start();
include 'header.php';
include 'db.php';
// Check if user is logged in
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
exit();
}
// Get post ID from URL
$post_id = isset($_GET['post_id']) ? intval($_GET['post_id']) : 0;
if ($post_id <= 0) {
echo "Invalid post ID.";
exit();
}
// Fetch post from database
$sql = "SELECT * FROM posts WHERE post_id = $post_id";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
?>
<body>
<header>
<nav>
<ul>
<li><a href="index.php">Index</a></li>
<li><a href="/all_posts.php">All Posts</a></li>
<li><a href="/user_panel.php">User Panel</a></li>
</ul>
</header>
<main>
<section>
<h1><?php echo $row['title']; ?></h1>
<p><?php echo $row['content']; ?></p>
</section>
</script>
<footer>
<p>© 2023 Voorivex Weblog System. All rights reserved.</p>
</footer>
</body>
</html>