forked from bindle03/ewbUHMembershipManagement
-
Notifications
You must be signed in to change notification settings - Fork 0
/
newMember.php
60 lines (52 loc) · 1.9 KB
/
newMember.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
<?php
# function to add new member after a form is submitted
session_start();
include 'nav.php';
require_once "pdo.php";
$message = '';
if (isset($_POST['uh_id']) && isset($_POST['first_name']) && isset($_POST['last_name'])) {
if (($_POST['uh_id']) == '' || ($_POST['first_name']) == '' || ($_POST['last_name']) == '') {
$message = '<p style="color:red">Please fill in all the information</p>';
} else {
$message = '<p style="color:green">Submitted</p>';
$sql = "INSERT INTO members (uh_id, first_name, last_name, semester_id) VALUES (:uh_id, :first_name, :last_name, :semester_id);
INSERT INTO event_details (event_id, member_id, attended, semester_id) VALUES(:event_id, LAST_INSERT_ID(), 1, :semester_id)";
$stmt = $pdo->prepare($sql);
$stmt->execute(
array(
':uh_id' => $_POST['uh_id'],
':first_name' => $_POST['first_name'],
':last_name' => $_POST['last_name'],
':event_id' => $_SESSION['id'],
':semester_id' => $_GET['semester_id']
)
);
}
;
}
?>
<html>
<head>
<!-- CSS -->
<link rel="stylesheet" href="resources\css\signup.css">
<title>Welcome</title>
</head>
<body>
<div class="container">
<h1>Welcome to Engineers Without Borders</h1>
<form method="post">
<label for="uhid"><b>UH ID</b></label>
<input id="uhid" type="text" name="uh_id"><br />
<label for="firstName"><b>First Name</b></label>
<input id="firstName" type="text" name="first_name"><br />
<label for="lastName"><b>Last Name</b></label>
<input id="lastName" type="text" name="last_name"><br />
<p><input type="submit" value="Submit">
<input type="button" onclick="location.href='events.php?semester_id=<?=$_GET['semester_id']?>'; return false;"
value="Back">
</p>
</form>
<?php echo ($message) ?>
</div>
</body>
</html>