-
Notifications
You must be signed in to change notification settings - Fork 2
/
dept_postwork4.php
348 lines (290 loc) · 8.96 KB
/
dept_postwork4.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
<?php session_start(); ?>
<!DOCTYPE HTML>
<html>
<head>
<title>
POST WORKS
</title>
<link rel="stylesheet" href="style.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="w3.css">
<link rel="stylesheet" href="w3-theme-black.css">
<style>
body {margin:0;}
.topnav {
overflow: hidden;
background-color: #333;
}
.topnav a {
float: left;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.topnav a:hover {
background-color: #ddd;
color: black;
}
.topnav a.active {
background-color: #4CAF50;
color: white;
}
.mainbox {
float: right;
background-color: green;
width: 50%;
border: 5px solid blue;
padding: 25px;
margin: 25px;
margin-right: 300px;
box-shadow: 5px 6px 7px;
padding-left: 80px;
padding-right: 80px;
}
.leftbox {
float: left;
background-color: red;
width: 15%;
border: 5px solid black;
padding: 25px;
margin: 25px;
box-shadow: 5px 6px 7px;
}
</style>
</head>
<body>
<!-- Top navigation bar-->
<div class="topnav">
<a href="departmenthomepage.php">Home</a>
<a class="active" href="dept_postwork.php">Post Work</a>
<a href="dept_approvework.php">Approve Work</a>
<a href="dept_approvehours.php">Approve Hours</a>
<a href="dept_studentdetails.php">Student Details</a>
<a href="dept_editdetails.php">Edit Details</a>
</div>
<div style="text-align: center;">
<h2>Post Work</h2>
</div>
<?php
$servername = "localhost";
$username = "root";
$password = "time.org";
$dbname = "seproject";
// Create $connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT Name,Email,ContactNumber,ContactPerson FROM Department where Name='CSED'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
echo "<br><br>";
while($row = $result->fetch_assoc()){
echo "<div class='w3-col m3'>";
echo "<div class='w3-card w3-round w3-white'>";
echo "<div class='w3-container'>";
echo "<h4 class='w3-center'> " .$row["Name"]. "</h4>";
echo "<p class='w3-center'><img src='bc2.jpg' class='w3-circle' style='height:106px;width:106px' alt='Avatar'></p>";
echo '<hr>';
echo "<p>Contact Person: " .$row["ContactPerson"]. "</p>";
echo "<p>Contact No: " .$row["ContactNumber"]. "</p>";
echo "<p>Email: " .$row["Email"]. "</p>";
echo "</div>";
echo "</div>";
echo "</div>";
echo "<br>";
}
} else {
echo "RECORD NOT FOUND";
exit;
}
?>
<div class="mainbox">
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<H3>
<table>
<tr>
<td>NAME:</td>
<td><input type="text" name="work_name"></td>
</tr>
<tr>
<td>DURATION IN HOURS:</td>
<td><input type="number" name="duration" min="0"> </td>
</tr>
<tr>
<td>DESCRIPTION:</td>
<td><input type="text" name="description" placeholder="Include StartTime,EndTime And Location" style="width: 500px; padding: 2px; border: 1px solid black"/> </td>
</tr>
<tr>
<td>DEADLINE TO APPLY:</td>
<td><input type="date" name="deadline"> </td>
</tr>
<tr>
<td colspan="2"><center> SELECT AS MANY AS POSSIBLE</center></td>
</tr>
<tr>
<td><center>INTERESTS:</center></td>
</tr>
<tr>
<td><input type="checkbox" name="interests[]" value="Painting"> Painting</td>
<td><input type="checkbox" name="interests[]" value="Books"> Books</td>
</tr>
<tr>
<td><input type="checkbox" name="interests[]" value="Gardening"> Gardening</td>
<td><input type="checkbox" name="interests[]" value="Teaching"> Teaching </td>
</tr>
<tr>
<td><input type="checkbox" name="interests[]" value="Coding"> Coding</td>
<td><input type="checkbox" name="interests[]" value="Designing"> Designing</td>
</tr>
<tr>
<td><input type="checkbox" name="interests[]" value="Hardware"> Hardware </td>
<td><input type="checkbox" name="interests[]" value="NGO Work"> NGO Work</td>
</tr>
<tr>
<td><input type="checkbox" name="interests[]" value="Organising"> Organising</td>
<td><input type="checkbox" name="interests[]" value="Counselling"> Counselling</td>
</tr>
<tr>
<td><input type="checkbox" name="interests[]" value="Mentoring"> Mentoring</td>
<td><input type="checkbox" name="interests[]" value="Sports"> Sports</td>
</tr>
<tr>
<td><input type="checkbox" name="interests[]" value="Renovation"> Renovation</td>
<td><input type="checkbox" name="interests[]" value="Donating Blood"> Donating Blood</td>
</tr>
<tr>
<td><input type="checkbox" name="interests[]" value="Health & Fitness"> Health & Fitness</td>
<td><input type="checkbox" name="interests[]" value="Management"> Management</td>
</tr>
<tr>
<td><input type="checkbox" name="interests[]" value="Recycling"> Recycling</td>
<td><input type="checkbox" name="interests[]" value="Surveying"> Surveying </td>
</tr>
<tr>
<td><input type="checkbox" name="interests[]" value="Manual Work"> Manual Work</td>
<td><input type="checkbox" name="interests[]" value="Cleaning"> Cleaning </td>
</tr>
<tr>
<td>TYPE:</td>
</tr>
<tr>
<td><input type="radio" value="Private" name="type">Private</td>
<td><input type="radio" value="Public" name="type">Public</td>
</tr>
</table>
</H3>
<input type="submit">
</form>
</div>
<?php
if($_SERVER["REQUEST_METHOD"] == "POST"){
$servername = "localhost";
$username = "root";
$password = "time.org";
$dbname = "seproject";
// Create $connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
function IsChecked($chkname,$value)
{
if(!empty($_POST[$chkname]))
{
foreach($_POST[$chkname] as $chkval)
{
if($chkval == $value)
{
return true;
}
}
}
return false;
}
// set parameters and execute
$name=$_POST["work_name"];
$duration=$_POST["duration"];
$description=$_POST["description"];
$interests=$_POST["interests"];
$deadline=$_POST["deadline"];
$type=$_POST["type"];
$deptname = "CSED";
$conn->query("INSERT INTO Work (Name, DeptName, Description, Duration, Type, DeadlineToApply) VALUES ('$name', '$deptname', '$description', '$duration', '$type', '$deadline')");
$current=mysqli_insert_id($conn);
$conn->query("INSERT INTO WorkInterests (WorkID) VALUES ('$current')");
if(IsChecked('interests','Painting')){
$conn->query("UPDATE WorkInterests SET I1 = 1 WHERE WorkID = ".$current."");
}
if(IsChecked('interests','Books')){
$conn->query("UPDATE WorkInterests SET I2 = 1 WHERE WorkID = ".$current."");
}
if(IsChecked('interests','Cleaning')){
$conn->query("UPDATE WorkInterests SET I3 = 1 WHERE WorkID = ".$current."");
}
if(IsChecked('interests','Gardening')){
$conn->query("UPDATE WorkInterests SET I4 = 1 WHERE WorkID = ".$current."");
}
if(IsChecked('interests','Teaching')){
$conn->query("UPDATE WorkInterests SET I5 = 1 WHERE WorkID = ".$current."");
}
if(IsChecked('interests','Coding')){
$conn->query("UPDATE WorkInterests SET I6 = 1 WHERE WorkID = ".$current."");
}
if(IsChecked('interests','Designing')){
$conn->query("UPDATE WorkInterests SET I7 = 1 WHERE WorkID = ".$current."");
}
if(IsChecked('interests','Hardware')){
$conn->query("UPDATE WorkInterests SET I8 = 1 WHERE WorkID = ".$current."");
}
if(IsChecked('interests','NGO Work')){
$conn->query("UPDATE WorkInterests SET I9 = 1 WHERE WorkID = ".$current."");
}
if(IsChecked('interests','Organising')){
$conn->query("UPDATE WorkInterests SET I10 = 1 WHERE WorkID = ".$current."");
}
if(IsChecked('interests','Counselling')){
$conn->query("UPDATE WorkInterests SET I11 = 1 WHERE WorkID = ".$current."");
}
if(IsChecked('interests','Mentoring')){
$conn->query("UPDATE WorkInterests SET I12 = 1 WHERE WorkID = ".$current."");
}
if(IsChecked('interests','Sports')){
$conn->query("UPDATE WorkInterests SET I13 = 1 WHERE WorkID = ".$current."");
}
if(IsChecked('interests','Renovation')){
$conn->query("UPDATE WorkInterests SET I14 = 1 WHERE WorkID = ".$current."");
}
if(IsChecked('interests','Donating Blood')){
$conn->query("UPDATE WorkInterests SET I15 = 1 WHERE WorkID = ".$current."");
}
if(IsChecked('interests','Health & Fitness')){
$conn->query("UPDATE WorkInterests SET I16 = 1 WHERE WorkID = ".$current."");
}
if(IsChecked('interests','Management')){
$conn->query("UPDATE WorkInterests SET I17 = 1 WHERE WorkID = ".$current."");
}
if(IsChecked('interests','Recycling')){
$conn->query("UPDATE WorkInterests SET I18 = 1 WHERE WorkID = ".$current."");
}
if(IsChecked('interests','Surveying')){
$conn->query("UPDATE WorkInterests SET I19 = 1 WHERE WorkID = ".$current."");
}
if(IsChecked('interests','Manual Work')){
$conn->query("UPDATE WorkInterests SET I20 = 1 WHERE WorkID = ".$current."");
}
echo "Works Posted<br>" ;
if($type == "Private") {
$_SESSION['WorkID'] = $current;
header('Location: dept_post_work_select_students.php');
}
$conn->close();
}
?>
</body>
</html>