This repository was archived by the owner on May 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadd.php
More file actions
executable file
·196 lines (160 loc) · 7.33 KB
/
add.php
File metadata and controls
executable file
·196 lines (160 loc) · 7.33 KB
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
<?php
include 'secrets.php';
if (isset($_POST['id'])) {
$db = mysqli_connect("localhost", "root", MYSQL_SECRET, $dbname);
if (!$db) {
die('<p class="error">Connect Error ('.mysqli_connect_errno().') '. mysqli_connect_error()."</p>");
}
$name = $db->real_escape_string($_POST['name']);
$email = $db->real_escape_string($_POST['email']);
$enterer = $db->real_escape_string($_POST['enterer']);
$id = hash('sha512', $_POST['id']);
$committee = $db->real_escape_string($_POST['committee']);
$query = "INSERT INTO `2021-2022` (name, email, id, enterer, committee) VALUES ('$name', '$email', '$id', '$enterer', '$committee')";
$db->query($query);
exit();
}
?>
<?php
$title = "Add Members";
include 'header.php';
?>
<!-- Page Heading/Breadcrumbs -->
<div class="row">
<div class="col-lg-12">
<h1 class="page-header"><?php echo $title ?></h1>
<ol class="breadcrumb">
<li><a href="index.php">Home</a>
</li>
<li class="active"><?php echo $title ?></li>
</ol>
</div>
</div>
<!-- Well -->
<div class="well">
<div id="error-box" class="row" style="display: none">
<div class="col-lg-8 col-lg-offset-2">
<div class="alert alert-danger"></div>
</div>
</div>
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<div class="form-group text-dark">
<label for="name-input" style="font-size: 45px;">Name:</label>
<input class="form-control input-lg" id="name-input" type="text">
</div>
<div class="form-group text-dark">
<label for="email-input" style="font-size: 45px;">Email:</label>
<input class="form-control input-lg" id="email-input" type="email">
</div>
<div class="form-group text-dark">
<label for="id-input" style="font-size: 45px;">Purdue ID:</label>
<input class="form-control input-lg" id="id-input" type="password">
</div>
<div class="form-group text-dark" id="committees" style="font-size: 20px;">
<label for="id-input" style="font-size: 45px;">Committees: </label><br />
<div class="checkbox">
<input type="checkbox" class="committees-checkbox" value="Aerial Robotics">Aerial Robotics</input>
</div>
<div class="checkbox">
<input type="checkbox" class="committees-checkbox" value="Computer Society">Computer Society</input>
</div>
<div class="checkbox">
<input type="checkbox" class="committees-checkbox" value="EMBS">EMBS</input>
</div>
<div class="checkbox">
<input type="checkbox" class="committees-checkbox" value="MTT-S">MTT-S</input>
</div>
<div class="checkbox">
<input type="checkbox" class="committees-checkbox" value="Racing">Racing</input>
</div>
<div class="checkbox">
<input type="checkbox" class="committees-checkbox" value="ROV">ROV</input>
</div>
<div class="checkbox">
<input type="checkbox" class="committees-checkbox" value="Software Saturdays">Software Saturdays</input>
</div>
<div class="checkbox">
<input type="checkbox" class="committees-checkbox" value="Growth and Engagement">Growth and Engagement</input>
</div>
<div class="checkbox">
<input type="checkbox" class="committees-checkbox" value="Industrial Relations">Industrial Relations</input>
</div>
<div class="checkbox">
<input type="checkbox" class="committees-checkbox" value="Learning">Learning</input>
</div>
<div class="checkbox">
<input type="checkbox" class="committees-checkbox" value="Social">Social</input>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<div class="form-group text-dark">
<label for="enterer-input" style="font-size: 45px;">Who is entering this info? (Only for officers to fill in)</label>
<input class="form-control input-lg" id="enterer-input" type="text">
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-lg-offset-3 text-center" style="padding-top: 25px">
<button type="button" class="btn btn-primary btn-lg" onclick="submit()">Submit</button>
</div>
</div>
</div>
<!-- /.well -->
<!-- jQuery -->
<script src="js/jquery.js"></script>
<script type="application/javascript">
function submit() {
var name = $("#name-input").val();
var email = $("#email-input").val();
var id = $("#id-input").val();
var enterer = $("#enterer-input").val();
var committee = $(".committees-checkbox").map(function() {
return this.checked ? this.value : "";
}).get().filter(s => s.length > 0).join(", ");
if(committee == "") {
committee = "None";
}
var error = "";
var namePattern = /^([a-zA-Z0-9-_'.]+\s*){2,}$/g;
var emailPattern = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
if (!namePattern.test(name)) {
error = "Please make sure the name only contains a-z, 0-9, ., ', -, or _. <BR>";
}
if (!emailPattern.test(email)) {
error += "Please make sure the email is valid. <BR>";
}
id = id.match(/00[0-9]{8}/);
if (id == null) {
error += "Please enter a valid id (10 numbers). <BR>";
} else {
id = id[0];
}
if (enterer.length < 1) {
error += "Please make sure you specify who is entering this information. <BR>";
}
if (error.length > 0) {
$(".alert-danger").html(error);
$("#error-box").show();
} else {
$.post("add.php", {
name: name,
email: email,
id: id,
enterer: enterer,
committee: committee
}, function(data) {
$("#name-input").val("");
$("#email-input").val("");
$("#id-input").val("");
// $(".committees-checkbox").each(function() { this.checked = false; } ); // Uncomment to reset checkboxes after submit
});
}
}
</script>
<?php
include 'footer.php';
?>