forked from bindle03/ewbUHMembershipManagement
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkin.php
101 lines (84 loc) · 3.94 KB
/
checkin.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
<?php
session_start(); //for password
include 'navBlank.php';
include 'pass.php';
require_once "pdo.php";
$message = '';
$event_stmt = $pdo->query("SELECT event_name FROM meetings WHERE event_id = " . $_GET['event_id']);
$row = $event_stmt->fetch(PDO::FETCH_ASSOC);
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$salt = 'XyZzy12*_';
if (empty($_POST['uh_id'])) {
$message = 'Enter your UH ID';
} else if (isset($_POST['uh_id'])) {
// check if uh_id exists or not
$uhid_lookup_stmt = $pdo->prepare("SELECT member_id, semester_id FROM members WHERE uh_id = ? LIMIT 1");
$uhid_lookup_stmt->execute([$_POST['uh_id']]);
$row2 = $uhid_lookup_stmt->fetch(PDO::FETCH_ASSOC);
// check if member exist in semester detail table for the current semester
if ($uhid_lookup_stmt->rowCount() == 1) { // UH ID found
$message = '<p style="color:green">Updated. Welcome back!</p>'; // update message
if($row2['semester_id'] < $_GET['semester_id']){
$member_lookup_stmt = $pdo->query("SELECT member_id, semester_id FROM semester_details WHERE semester_id = " . $_GET['semester_id'] .
" AND member_id = " . $row2['member_id'] . " LIMIT 1");
if ($member_lookup_stmt->rowCount() == 0) { // member not found in the current semester roster
$sql_insert = "INSERT INTO semester_details (semester_id, member_id, member_type_id) VALUES (:semester_id, :member_id, 1);
INSERT INTO event_details (event_id, member_id, attended, semester_id) VALUES (:event_id, :member_id, 1, :semester_id)";
$stmt_insert = $pdo->prepare($sql_insert);
$stmt_insert->execute(
array(
':uh_id' => $_POST['uh_id'],
':event_id' => $_GET['event_id'],
':semester_id'=> $_GET['semester_id'],
':member_id' => $row2['member_id'],
)
);
} else { //member found in the current semester roster
$sql_update = "UPDATE event_details INNER JOIN members ON event_details.member_id = members.member_id SET event_details.attended = 1
WHERE members.uh_id = :uh_id AND event_details.event_id = :event_id";
// update attendance for looked-up UH ID
$stmt_update = $pdo->prepare($sql_update);
$stmt_update->execute(
array(
':uh_id' => $_POST['uh_id'],
':event_id' => $_GET['event_id'],
)
);
}
}
} else { // UH ID not found
$message = '<p style="color:red">UH ID Not Found</p>'; // update message
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login</title>
<link rel="stylesheet" href="resources\css\signup.css">
<link rel="stylesheet" href="resources\css\table.css">
</head>
<body>
<div class="heading">
<h1><?=$row['event_name']?></h1>
</div>
<div class="container">
<form method="post">
<label for="uhid" style="color: black"><b>UH ID</b></label>
<input id="uhid" type="text" name="uh_id"><br />
<input type="submit" value="Submit">
</form>
<p class="error-message">
<?php echo ($message) ?>
</p>
</div>
<div class="container" style="display: flex">
<br/>
<h3>UH ID not found, click ></h3>
<a class="newEvent" href="member_newMember.php?event_id=<?= $_GET['event_id'] ?>&semester_id=<?= $_GET['semester_id']?>" rel="nofollow noopener">New Member</a>
</div>
</body>
</html>