-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost2.html
189 lines (169 loc) · 7.85 KB
/
post2.html
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Victoria Falls - Zimbabwe</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
<style>
.blog-post-thumbnail {
width: 100%;
height: 300px;
object-fit: cover;
}
.blog-content {
margin-top: 30px;
}
</style>
</head>
<body>
<!-- Navbar -->
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Destinations</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="About.html">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.html">Contact</a>
</li>
</ul>
</div>
</nav>
<!-- Blog Post Content -->
<div class="container blog-content">
<h1>Victoria Falls, Zimbabwe</h1>
<img src="images/Scenic View at Victoria Falls (1).jpg" alt="Victoria Falls" class="post thumbnail"
width="250" height="200">
<img src="images/The Boma experience in Victoria Falls, Zimbabwe.jpg" alt="Victoria Falls" class="post thumbnail"
width="250" height="200">
<img src="images/Zimbabwe Flag, Flags of Various Countries, Republic of Zimbabwe Polyester, Indoor Outdoor 90X150cm - 90x150 cm.jpg"
width="250" height="200">
<p class="post thumbnail">Victoria Falls is one of the largest and most famous waterfalls in the world, located on the Zambezi River on the border between Zimbabwe and Zambia.</p>
<h3>Attractions:</h3>
<ul>
<li><strong>The Falls:</strong> A breathtaking sight, especially during the rainy season when the falls are in full flow.</li>
<li><strong>Victoria Falls Bridge:</strong> A historic bridge spanning the Zambezi River, offering spectacular views of the falls.</li>
<li><strong>Devil’s Pool:</strong> A natural infinity pool located at the edge of the falls, offering an exhilarating experience for the brave-hearted.</li>
</ul>
<h3>Best Time to Visit:</h3>
<p>The best time to visit Victoria Falls is from February to May when the falls are at their peak flow, but the views are stunning year-round.</p>
<h3>Things to Do:</h3>
<p>Experience a helicopter flight over the falls, go white-water rafting on the Zambezi River, or take a sunset cruise along the river for a relaxing experience.</p>
</div>
<?php
// Database connection
$host = 'localhost';
$dbname = 'blog_comments';
$username = 'root';
$password = 'Reabetsweneo03#';
$conn = new mysqli($host, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Get the post ID from the URL
$post_id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
// Fetch the post content
$sql = "SELECT * FROM posts WHERE id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $post_id);
$stmt->execute();
$post_result = $stmt->get_result();
$post = $post_result->fetch_assoc();
// Fetch comments for this post
$sql_comments = "SELECT * FROM comments WHERE post_id = ? ORDER BY created_at DESC";
$stmt_comments = $conn->prepare($sql_comments);
$stmt_comments->bind_param("i", $post_id);
$stmt_comments->execute();
$comments_result = $stmt_comments->get_result();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo htmlspecialchars($post['title']); ?> - Rhea Travels</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<!-- Navbar -->
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Destinations</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="About.html">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.html">Contact</a>
</li>
</ul>
</div>
</nav>
<!-- Blog Post -->
<div class="container my-5">
<h1><?php echo htmlspecialchars($post['title']); ?></h1>
<p><?php echo nl2br(htmlspecialchars($post['content'])); ?></p>
<!-- Comment Form -->
<h3>Leave a Comment:</h3>
<form method="POST" action="submit_comment.php?post_id=<?php echo $post_id; ?>">
<div class="form-group">
<label for="name">Your Name</label>
<input type="text" class="form-control" id="name" name="name" required>
</div>
<div class="form-group">
<label for="comment">Your Comment</label>
<textarea class="form-control" id="comment" name="comment" rows="3" required></textarea>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
<!-- Display Comments -->
<h3>Comments:</h3>
<?php if ($comments_result->num_rows > 0): ?>
<?php while ($comment = $comments_result->fetch_assoc()): ?>
<div class="media my-4">
<div class="media-body">
<h5 class="mt-0"><?php echo htmlspecialchars($comment['name']); ?></h5>
<p><?php echo nl2br(htmlspecialchars($comment['comment'])); ?></p>
<small>Posted on: <?php echo $comment['created_at']; ?></small>
</div>
</div>
<?php endwhile; ?>
<?php else: ?>
<p>No comments yet.</p>
<?php endif; ?>
</div>
<!-- Footer -->
<footer class="footer">
<p>© 2024 Rhea Travels. All Rights Reserved.</p>
</footer>
<!-- Bootstrap JS and dependencies -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>
<!-- Footer -->
<footer class="footer bg-light text-center py-3">
<p>© 2024 My Blog. All Rights Reserved.</p>
</footer>
<!-- Bootstrap JS and dependencies -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>