-
Notifications
You must be signed in to change notification settings - Fork 0
/
addAnnouncement.php
355 lines (336 loc) · 10.8 KB
/
addAnnouncement.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
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
<?php
// Check if the user is logged in and has the admin role
session_start();
if (!isset($_SESSION['role']) || $_SESSION['role'] != 'admin') {
header('Location: login.php');
exit;
}
// Create a connection to the database
$db_host = 'localhost';
$db_username = 'root';
$db_password = '';
$db_name = 'tga';
$conn = new mysqli($db_host, $db_username, $db_password, $db_name);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Create a new announcement
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$title = $_POST['title'];
$description = $_POST['description'];
$role = $_SESSION['role'];
// Check if adminID is set in the session
if (isset($_SESSION['adminID'])) {
$postedBy = $_SESSION['adminID'];
} else {
// If adminID is not set, display an error message
echo "Error: adminID is not set in the session.";
exit;
}
// Get the posted date from the form
$postedDate = $_POST['postedDate']; // Should be in 'Y-m-d' format
$query = "INSERT INTO announcements (title, description, postedDate, postedBy, role) VALUES (?, ?, ?, ?, ?)";
$stmt = $conn->prepare($query);
$stmt->bind_param("sssss", $title, $description, $postedDate, $postedBy, $role);
$stmt->execute();
if ($stmt) {
header('Location: adminhome.php');
exit;
} else {
echo "Error: " . $conn->error;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Add Announcement - TechGenius Academy</title>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@700&family=Roboto&display=swap" rel="stylesheet">
<!-- FontAwesome Icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css">
<!-- Custom CSS -->
<style>
body, html {
height: 100%;
margin: 0;
padding: 0;
font-family: 'Roboto', sans-serif;
overflow-x: hidden;
background-color: rgba(255, 255, 255, 0.4);
/* Background Image */
background-image: url('https://wallpapers.com/images/hd/anime-school-scenery-empty-classroom-oemz67vnyqdihizw.jpg');
background-size: cover;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-blend-mode: overlay;
}
/* Spinner Styles */
#spinner {
position: fixed;
display: flex;
align-items: center;
justify-content: center;
background-color: #fff;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 9999;
transition: opacity 0.5s ease-out;
}
#spinner.show {
opacity: 1;
visibility: visible;
}
#spinner.hide {
opacity: 0;
visibility: hidden;
}
.spinner-border {
width: 3rem;
height: 3rem;
}
.sidebar {
position: fixed;
top: 0;
left: 0;
height: 100vh;
width: 220px;
background-color: #0069d9;
padding: 20px;
border-right: 3px solid rgba(255, 193, 7, 0.8);
overflow-y: auto;
}
.sidebar .school-logo {
margin-bottom: 20px;
text-align: center;
}
.sidebar .school-logo img {
width: 100px;
height: 100px;
border-radius: 50%;
border: 2px solid #fafafa;
}
.sidebar .nav {
flex-direction: column;
}
.sidebar .nav-item {
margin-bottom: 10px;
}
.sidebar .nav-link {
color: #fff;
font-weight: 500;
padding: 10px;
border-radius: 5px;
}
.sidebar .nav-link:hover, .sidebar .nav-link.active {
background-color: rgba(255, 193, 7, 0.8);
color: #fff;
}
.sidebar .nav-link i {
margin-right: 10px;
}
.logout-button {
position: absolute;
bottom: 20px;
left: 20px;
}
.logout-button a {
color: #fff;
text-decoration: none;
transition: color 0.2s ease;
}
.logout-button a:hover {
color: rgba(255, 193, 7, 0.8);
}
/* Main content area */
.main-content {
margin-left: 220px;
padding: 20px;
}
.header-banner {
width: 100%;
text-align: center;
background-color: #0069d9;
color: #fff;
padding: 20px 0;
margin-bottom: 20px;
}
.header-banner .title {
font-size: 36px;
font-weight: 900;
font-family: 'Orbitron', sans-serif;
margin: 0;
}
.header-banner .subtitle {
font-size: 24px;
margin: 0;
}
.page-title {
text-align: center;
margin-bottom: 30px;
color: rgba(255, 193, 7, 0.8);
}
.page-title h1 {
font-family: 'Orbitron', sans-serif;
}
/* Form Styles */
.form-container {
background-color: rgba(255, 255, 255, 0.8);
padding: 30px;
border-radius: 10px;
max-width: 800px;
margin: 0 auto;
}
.form-group label {
font-weight: bold;
color: #0069d9;
}
.btn-primary {
background-color: #ffc107;
border: none;
color: #000;
font-weight: bold;
border-radius: 20px;
padding: 10px 20px;
margin-top: 20px;
}
.btn-primary:hover {
background-color: #e0a800;
color: #000;
}
/* Footer */
footer {
background-color: #0069d9;
padding: 20px;
color: #fff;
text-align: center;
position: relative;
}
footer a {
color: #ffc107;
text-decoration: none;
}
footer a:hover {
color: #e0a800;
}
footer .footer-logo {
position: absolute;
left: 20px;
top: 50%;
transform: translateY(-50%);
}
footer .footer-logo img {
width: 50px;
height: 50px;
}
/* Responsive adjustments */
@media (max-width: 991.98px) {
.sidebar {
position: relative;
width: 100%;
height: auto;
}
.main-content {
margin-left: 0;
}
footer .footer-logo {
position: static;
transform: none;
margin-bottom: 10px;
}
}
</style>
</head>
<body>
<!-- Spinner Start -->
<div id="spinner" class="show">
<div class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<!-- Spinner End -->
<!-- Sidebar -->
<div class="sidebar">
<div class="school-logo">
<img src="logo.png" alt="School Logo" class="img-fluid rounded-circle">
</div>
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link" href="adminhome.php"><i class="fas fa-tachometer-alt"></i> Dashboard</a>
</li>
<li class="nav-item">
<a class="nav-link" href="manageTeachers.php"><i class="fas fa-chalkboard-teacher"></i> Manage Teachers</a>
</li>
<li class="nav-item">
<a class="nav-link" href="manageStudents.php"><i class="fas fa-user-graduate"></i> Manage Students</a>
</li>
<li class="nav-item">
<a class="nav-link" href="manageCourses.php"><i class="fas fa-book"></i> Manage Courses</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="announcements.php"><i class="fas fa-bullhorn"></i> Announcements</a>
</li>
</ul>
<div class="logout-button">
<a href="logout.php"><i class="fas fa-sign-out-alt"></i> Logout</a>
</div>
</div>
<!-- Sidebar End -->
<!-- Main Content -->
<div class="main-content">
<!-- Header Banner -->
<div class="header-banner">
<span class="title">TECHGENIUS ACADEMY</span><br>
<span class="subtitle">Unlock Your Potential, Empower Your Future!</span>
</div>
<!-- Page Title -->
<div class="page-title">
<h1>Add Announcement</h1>
</div>
<!-- Form Container -->
<div class="form-container">
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
<div class="form-group">
<label for="title">Title:</label>
<input type="text" class="form-control" id="title" name="title" required>
</div>
<div class="form-group">
<label for="postedDate">Date:</label>
<input type="date" class="form-control" id="postedDate" name="postedDate" required>
</div>
<div class="form-group">
<label for="description">Description:</label>
<textarea class="form-control" id="description" name="description" rows="5" required></textarea>
</div>
<button type="submit" class="btn btn-primary" name="submit">Add Announcement</button>
</form>
</div>
<!-- Footer -->
<footer>
<!-- Small School Logo -->
<div class="footer-logo">
<img src="logo.png" alt="School Logo">
</div>
<p>© 2023 TechGenius Academy | <a href="#">About Us</a> | <a href="#">Contact Us</a> | <a href="#">Terms of Use</a> | <a href="#">Privacy Policy</a></p>
</footer>
</div>
<!-- Main Content End -->
<!-- jQuery and Bootstrap JS (Required for the spinner and functionality) -->
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<!-- Spinner Script -->
<script>
$(window).on('load', function() {
setTimeout(function() {
$('#spinner').addClass('hide');
}, 500); // Adjust the timeout as needed
});
</script>
</body>
</html>