-
Notifications
You must be signed in to change notification settings - Fork 1
/
allothandler.php
57 lines (48 loc) · 2.17 KB
/
allothandler.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
<?php
session_start();
require("db.php");
// ================== Clean Request Handler =================== //
if (isset($_POST['allotSubmit']) && isset($_SESSION['username'])) {
$reqId = mysqli_real_escape_string($db, $_POST['allotId']);
$workerId = mysqli_real_escape_string($db, $_POST['workerId']);
$allot_query = "Update cleanrequest set worker_id = '$workerId', req_status=1 where request_id = '$reqId'";
$allot_result = mysqli_query($db, $allot_query);
if ($allot_result) {
$_SESSION['worker_alloted'] = "Housekeeper successfully alloted";
} else {
$_SESSION['allotment_failed'] = "Failed to allot worker, contact site management.";
}
header("Location: allot.php");
}
// Student Registration
if (isset($_POST['regSubmit']) && isset($_SESSION['username'])) {
$rollnumber = mysqli_real_escape_string($db, $_POST['regRoll']);
$roomnumber = mysqli_real_escape_string($db, $_POST['regRoom']);
$floornumber = mysqli_real_escape_string($db, $_POST['regFloor']);
$password = 12345;
$roomnumber = strtolower($roomnumber);
$hostel_name = 'UG2';
$reg_query = "Insert into student (rollnumber, password, room, floor, hostel) values ('$rollnumber', '$password', '$roomnumber', '$floornumber', '$hostel_name')";
$reg_result = mysqli_query($db, $reg_query);
if ($reg_result) {
$_SESSION['student_registered'] = 'Student with Rollnumber ' . $rollnumber . ' is Registered.';
} else {
$_SESSION['student_registered'] = 'Student is already Registered!';
}
header("Location: registerstudent.php");
}
// Worker Registration
if (isset($_POST['regKeeperSubmit']) && isset($_SESSION['username'])) {
$name = mysqli_real_escape_string($db, $_POST['regName']);
$floornumber = mysqli_real_escape_string($db, $_POST['regFloor']);
$hostel_name = substr($_SESSION['username'], -1);
$name = strtolower($name);
$reg_query = "Insert into housekeeper (name, hostel, floor) values ('$name', '$hostel_name', '$floornumber')";
$reg_result = mysqli_query($db, $reg_query);
if ($reg_result) {
$_SESSION['worker_registered'] = 'New Housekeeper Registered.';
} else {
$_SESSION['worker_registered'] = 'Resistration Failed!';
}
header("Location: registerworker.php");
}