-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroadupdate.php
More file actions
368 lines (318 loc) · 10.8 KB
/
roadupdate.php
File metadata and controls
368 lines (318 loc) · 10.8 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
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
<!--connect file-->
<?php
include('dbconnect.php');
?>
<!DOCTYPE html>
<html>
<head>
<title>Road Updates</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" />
<style>
/* Additional CSS styles for the update page */
.carousel {
width: 100%;
max-width: 1000px;
height: 400px;
margin: 20px auto;
overflow: hidden;
position: relative;
color: #005884;
}
.carousel-item {
display: none;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
animation: fade 5s infinite;
}
.carousel-item.active {
display: block;
}
.carousel-item .place-name {
font-size: 24px;
font-weight: bold;
text-align: center;
margin-bottom: 10px;
}
.carousel-item img {
width: 100%;
height: 100%;
object-fit: cover;
}
@keyframes fade {
0% {
opacity: 0;
}
20% {
opacity: 1;
}
80% {
opacity: 1;
}
100% {
opacity: 0;
}
}
.update-form {
max-width: 500px;
margin: 20px auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
color: #005884;
}
.update-form label,
.update-form input,
.update-form textarea,
.update-form button {
display: block;
margin-bottom: 15px;
}
.update-form textarea {
height: 100px;
}
.update-form button {
background-color:#cd4747;
color: #fff;
padding: 10px 20px;
border: none;
cursor: pointer;
}
.update-form button:hover {
background-color:#4CAF50;
}
.safety-precautions {
margin-top: 90px;
margin-left: 50px;
margin-right: 50px;
background-color:#cd4747;
}
.safety-precautions h3 {
font-size: 20px;
color: #005884;
font-weight: bold;
background-color:#f2f2f2;
margin-bottom: 10px;
}
.safety-precautions ul {
list-style-type: disc;
margin-left: 50px;
}
</style>
</head>
<body>
<!-- Navigation bar -->
<div class="header-top">
<div class="header-top-right">
<span> ☎ +977-1-5970646, 4211917</span>
<span>📩 Official: info@.gov.np</span>
<span>| Technical Support: govnp@rsms.gov.np</span>
</div>
</div>
<header class="header">
<nav class="navbar">
<div class="navbar-logo">
<img src="image/n.png" alt="Logo">
</div>
<ul class="navbar-menu">
<li><a href="index.html">Home</a></li>
<li><a href="roadupdate.php">Road Condition</a></li>
<li><a href="login.html"><i class="far fa-user"></i></a></li>
</ul>
<div class="navbar-flag">
<img src="image/nepalflag.gif" alt="Nepal Flag">
</div>
</nav>
</header>
<div class="header-news">
<marquee behavior="scroll" direction="left">News Update: Road condition of Nepal - Construction is going on the road in Bhaktapur.</marquee>
</div>
<div class="container">
<div class="row">
<div class="col-md-8">
<!-- Road condition carousel -->
<?php
// Fetch images and location names from the roadconditionupdates table
$query = "SELECT * FROM roadconditionupdates";
$result = mysqli_query($conn, $query);
// Store the fetched data in an array
$carouselItems = array();
while ($row = mysqli_fetch_assoc($result)) {
$image = $row['road_update_image1'];
$location = $row['Location'];
$Description = $row['Description'];
$Source = $row['Source'];
// Add the image and location to the carousel items array
$carouselItems[] = array('image' => $image, 'location' => $location);
}
?>
<!-- Display the carousel -->
<div class="carousel">
<?php foreach ($carouselItems as $item): ?>
<div class="carousel-item">
<div class="place-name"><?php echo $item['location']; ?></div>
<img src="road_update_images/<?php echo $item['image']; ?>" alt="<?php echo $item['location']; ?>">
<div class="main-carousel-description">
<h4> <p><?php echo $Description?></p> </h4>
<p>Source:<?php echo $Source?></p>
</div>
</div>
<?php endforeach; ?>
</div>
<!--section class="carousel">
<div id="road-carousel" class="carousel-item active">
<div class="place-name">Balkumari</div>
<img src="image/ro.jpg" alt="Balkumari Road Condition">
</div>
<div class="carousel-item">
<div class="place-name">Bhaktapur</div>
<img src="image/roo.jpg" alt="Bhaktapur Road Condition">
</div>
<div class="carousel-item">
<div class="place-name">Koteshwor</div>
<img src="image/r.jpg" alt="Koteshwor Road Condition">
</div>
<div class="carousel-item">
<div class="place-name">Maitighar</div>
<img src="image/rr.jpg" alt="Maitighar Road Condition">
</div>
<!-- Add more carousel items as needed -->
<!--/section-->
</div>
<div class="col-md-4">
<!-- Update form -->
<section class="update-form">
<h2>Submit Road Update</h2>
<form action="" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="updatelocation">Location*</label>
<input type="text" id="updatelocation" name="updatelocation" class="form-control" required>
</div>
<div class="form-group">
<label for="roadcondition">Road Condition*</label>
<textarea id="roadcondition" name="roadcondition" class="form-control" required></textarea>
</div>
<div class="form-group">
<label for="roadimage1">Upload Image*</label>
<input type="file" id="roadimage1" name="roadimage1" class="form-control-file" required>
</div>
<div class="form-group">
<label for="updaterepoter">Reporter Name*</label>
<input type="text" id="updaterepoter" name="updaterepoter" class="form-control" required>
</div>
<div class="form-group">
<label for="updaterepotercontact">Reporter Contact*</label>
<input type="text" id="updaterepotercontact" name="updaterepotercontact" class="form-control" required>
</div>
<div class="form-group">
<label for="roadimage2">Additional Image</label>
<input type="file" id="roadimage2" name="roadimage2" class="form-control-file">
</div><div class="form-group">
<label for="roadimage3">Additional Image</label>
<input type="file" id="roadimage3" name="roadimage3" class="form-control-file">
</div>
<div class="form-outline mb-4 w-50 m-auto">
<input type="submit" name="insert_user_report"
class="btn btn_info mb-3 p-3 bg-info" value="Submit">
</div>
</form>
</section>
</div>
<?php
global $conn; // assuming $con is the database connection variable
$select_query = 'SELECT * FROM `roadconditionupdates`';
$result_query = mysqli_query($conn, $select_query);
if (!$result_query) {
// Handle query error
echo "Error executing query: " . mysqli_error($con);
return;
}
while ($row = mysqli_fetch_assoc($result_query)) {
$UpdateID = $row['UpdateID'];
$Location = $row['Location'];
$Description = $row['Description'];
$Source = $row['Source'];
$road_update_image1 = $row['road_update_image1'];
echo "
<div class='col-6 col-md-4'>
<div class='card'>
<img class='card-img-top' src='road_update_images/$road_update_image1' alt='image'>
<div class='card-body'>
<h5 class='card-title'>$Location</h5>
<p class='card-text'>$Description</p>
<p class='card-text'>Soruce: $Source</p>
</div>
</div>
</div>";
}
?>
</div>
</div>
</div>
<?php
if (isset($_POST['insert_user_report'])) {
// Retrieve form data
$updatelocation = $_POST['updatelocation'];
$roadcondition = $_POST['roadcondition'];
$updaterepoter = $_POST['updaterepoter'];
$updaterepotercontact = $_POST['updaterepotercontact'];
// Handle file upload
$image1 = $_FILES['roadimage1']['name'];
$image1_tmp = $_FILES['roadimage1']['tmp_name'];
$image2 = $_FILES['roadimage2']['name'];
$image2_tmp = $_FILES['roadimage2']['tmp_name'];
$image3 = $_FILES['roadimage3']['name'];
$image3_tmp = $_FILES['roadimage3']['tmp_name'];
// Move uploaded files to a specific folder
move_uploaded_file($image1_tmp,"user_road_update_images/$image1");
move_uploaded_file($image2_tmp,"user_road_update_images/$image2");
move_uploaded_file($image3_tmp,"user_road_update_images/$image3");
// Prepare and execute the SQL query
$query = "INSERT INTO roadreport
(updatelocation, roadcondition, updaterepoter, updaterepotercontact, roadimage1, roadimage2, roadimage3,created_at)
VALUES ('$updatelocation', '$roadcondition', '$updaterepoter', '$updaterepotercontact', '$image1', '$image2', '$image3',NOW())";
$result = mysqli_query($conn, $query);
if ($result) {
// Data inserted successfully
echo "<script>alert('Road report submitted successfully')</script>";
} else {
// Error inserting data
echo "Error: " . mysqli_error($con);
}
}
?>
<!-- Safety precautions -->
<section class="safety-precautions">
<h3>Safety Precautions:</h3>
<ul>
<li>Observe speed limits and traffic signals.</li>
<li>Keep a safe distance from the vehicle in front of you.</li>
<li>Wear seatbelts and ensure all passengers do the same.</li>
<li>Use indicators and follow proper lane discipline.</li>
<li>Be cautious of pedestrians and follow pedestrian crossings.</li>
<li>Avoid using mobile phones while driving.</li>
<li>Adhere to road signs and instructions given by traffic police.</li>
</ul>
</section>
<script>
// JavaScript code to handle carousel animation
const carouselItems = document.querySelectorAll('.carousel-item');
let activeIndex = 0;
function showCarouselItem(index) {
carouselItems.forEach(item => item.classList.remove('active'));
carouselItems[index].classList.add('active');
}
function startCarousel() {
showCarouselItem(activeIndex);
activeIndex = (activeIndex + 1) % carouselItems.length;
setTimeout(startCarousel, 5000); // Change slide every 5 seconds
}
startCarousel();
</script>
</body>
</html>