-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsignup.php
More file actions
105 lines (93 loc) · 3.39 KB
/
Copy pathsignup.php
File metadata and controls
105 lines (93 loc) · 3.39 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
<?php
include_once "common/connection.php";
$pageTitle = "Sign Up";
include_once "common/header.php";
//define error variables and initialize with empty values
$useridErr = $nameErr = $passwordErr = $retypepassErr = $collegenameErr = $collegeaddressErr = "";
$userid = $username = $password = $retypepassword = $collegename = $collegeaddress = "";
$validate = false;
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$validate = true;
if(empty($_POST['userid'])) {
$useridErr = "Please enter a userID";
$validate = false;
}
else {
$userid = $_POST['userid'];
}
if(empty($_POST['username'])) {
$nameErr = "Please enter the username";
$validate = false;
}
else {
$username = $_POST['username'];
}
if(empty($_POST['password'])) {
$passwordErr = "Please enter a password";
$validate = false;
}
else {
$password = $_POST['password'];
}
if(empty($_POST['retypepassword'])) {
$retypepassErr = "Please re-type password";
$validate = false;
}
elseif($_POST['retypepassword'] != $_POST['password']) {
$retypepassErr = "Passwords don't match";
}
if(empty($_POST['collegename'])) {
$collegenameErr = "Please enter the college name";
$validate = false;
}
else {
$collegename = $_POST['collegename'];
}
if(empty($_POST['collegeaddress'])) {
$collegeaddressErr = "Please enter the college address";
$validate = false;
}
else {
$collegeaddress = $_POST['collegeaddress'];
}
}
if($validate === true) {
include_once "inc/class.users.inc.php";
$users = new Users($db);
if($users->createAccount() == TRUE)
echo "<div class='message good'>User has been successfully created</div>";
else {
$validate = false;
$useridErr = "UserID already exists. Please choose another.";
}
}
if($validate === false):
?>
<h2>Sign Up</h2> <br />
<form method="post" action="signup.php" id="signupform">
<div>
<label for="userid">UserID</label>
<input type="text" name="userid" id="userid" value="<?php echo htmlspecialchars($userid);?>" />
<span class="error"><?php echo $useridErr;?></span><br /><br />
<label for="username">Username</label>
<input type="text" name="username" id="username" value="<?php echo htmlspecialchars($username);?>" />
<span class="error"><?php echo $nameErr;?></span><br /><br />
<label for="password">Password</label>
<input type="password" name="password" id="password" value="<?php echo htmlspecialchars($password);?>" />
<span class="error"><?php echo $passwordErr;?></span> <br /><br />
<label for="retypepassword">Re-type Password</label>
<input type="password" name="retypepassword" id="retypepassword" value="<?php echo htmlspecialchars($retypepassword);?>" />
<span class="error"><?php echo $retypepassErr;?></span> <br/><br/>
<label for="collegename">College Name</label>
<input type="text" name="collegename" id="collegename" value="<?php echo htmlspecialchars($collegename);?>" />
<span class="error"><?php echo $collegenameErr;?></span> <br /><br />
<label for="collegeaddress">College Address</label>
<input type="textbox" name="collegeaddress" id="collegeaddress" value="<?php echo htmlspecialchars($collegeaddress);?>" />
<span class="error"><?php echo $collegeaddressErr;?></span> <br /><br />
<input type="submit" name="signup" id="signup" value="Sign Up" />
</div>
</form>
<?php
endif;
include_once "common/footer.php";
?>