-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsignUp_script.php
More file actions
66 lines (61 loc) · 2.05 KB
/
Copy pathsignUp_script.php
File metadata and controls
66 lines (61 loc) · 2.05 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
<?php
// require statement used to access the database; used in every file to retrieve db info
require_once 'server.php';
// variable names to be insert into User_Accounts table
$First_Name = $_POST['fname'];
$Last_Name = $_POST['lname'];
$User_Email = $_POST['email'];
$Password = $_POST['pword'];
$Password2 = $_POST['rpword'];
$Major = $_POST['major'];
$Classification = $_POST['yearstatus'];
$errors = array();
// make sure all fields are filled out properly
if (empty($First_Name)) {
array_push($errors, "First name is required. ");
}
if (empty($Last_Name)) {
array_push($errors, "Last name is required. ");
}
if (empty($User_Email)) {
array_push($errors, "An email address is required. ");
}
if (empty($Password)) {
array_push($errors, "Password is required. ");
}
if (empty($Password2)) {
array_push($errors, "Must re-enter password. ");
}
if ($Password != $Password2) {
array_push($errors, "The two passwords do not match. ");
}
if (empty($Major)) {
array_push($errors, "Must enter a major. ");
}
if (empty($Classification)) {
array_push($errors, "Must choose your classification. ");
}
echo count($errors);
// saves user to database if no errors present
if (count($errors) == 0) {
$accountsTable = "INSERT INTO User_Accounts (first_name, last_name, user_email, acc_password,
major, classification) VALUES" . "('$First_Name', '$Last_Name', '$User_Email', '$Password',
'$Major', '$Classification')";
//write inesert code
if ($trConnect->query($accountsTable)) {
echo "Your account has been successfully created";
$tyurl = "thankYou.html";
header('Location: '.$tyurl);
die();
} else {
echo "Error: ".$accountsTable;
}
} else {
// prints out the present errors
for ($numError = 0; $numError < count($errors); $numError++) {
echo "Errors: ".$errors[$numError];
}
$againurl = "signUpError.html";
header('Location: '.$againurl);
}
?>