-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsignup.php
87 lines (85 loc) · 3.49 KB
/
signup.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
<!DOCTYPE html>
<html lang="en">
<head>
<?php
/*
* signup.php
* Form to allow users to create an account.
* Account is required for posting reviews and adding professors and courses.
*/
?>
<meta charset="utf-8">
<title>Sign up | Rate my Professor</title>
<!-- Custom styles for this template -->
<link href="css/signup.css" rel="stylesheet">
<?php
include_once('db_connect.php');
include_once('links.html');
include('nav.php');
if (array_key_exists('signup_failed', $_SESSION)) {
$signupFailed = true;
$invalidUsername = array_key_exists('invalid_username', $_SESSION);
$invalidEmail = array_key_exists('invalid_email', $_SESSION);
$passwordMismatch = array_key_exists('password_mismatch', $_SESSION);
unset($_SESSION['signup_failed']);
} else {
$signupFailed = false;
}
?>
</head>
<body style="background: url('img/pattern.png');">
<div class="container">
<form class="form-signup" method="POST" action="signup-auth.php">
<?php
if ($signupFailed) {
printf("<div class='alert alert-danger'> <strong>Sign Up Failed !</strong> Please correct the following errors:");
if ($passwordMismatch) {
printf("<br>Your password and confirmation password do not match.");
}
if ($invalidUsername) {
printf("<br>The username you entered is already in use or is invalid.");
}
if ($invalidEmail) {
printf("<br>The email address you entered is already in use or is invalid.");
}
printf("</div>");
}
?>
<h2 class="form-signup-heading">Sign Up</h2>
<!--<input type="hidden" name="referer" value="<?php echo $lastPage; ?>"> -->
<?php
// Test redirect from $_GET
echo '<input type="hidden" name="location" value="';
if(isset($_GET['location'])) {
echo htmlspecialchars($_GET['location']);
}
if(isset($_GET['id'])) {
echo "?id=" . htmlspecialchars($_GET['id']);
}
echo '">';
printf("\n");
echo '<input type="hidden" name="append" value="';
if(isset($_GET['location'])) {
echo "?location=" . htmlspecialchars($_GET['location']);
}
if(isset($_GET['id'])) {
echo "&id=" . htmlspecialchars($_GET['id']);
}
echo '">';
?>
<div class="form-inline">
<input type="text" name='fname' class="form-control" placeholder="First Name"
style="width: 228px;!important;" required autofocus>
<input type="text" name='lname' class="form-control" placeholder="Last Name"
style="width: 228px;!important;" required>
</div>
<input type="username" name='username' class="form-control" placeholder="Username" required>
<input type="email" name='email' class="form-control" placeholder="Email Address" required>
<input type="password" name="password" class="form-control" placeholder="Password" required>
<input type="password" name="confirm_password" class="form-control" placeholder="Confirm Password" required>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign Up</button>
<p align="center"><a href="login.php">Already Registered? Sign in</a></p>
</form>
</div> <!-- /container -->
</body>
</html>