-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsignup.php
95 lines (74 loc) · 4.65 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
88
89
90
91
92
93
94
95
<?php
require_once("includes/config.php");
require_once("includes/classes/FormSanitizer.php");
require_once("includes/classes/Account.php");
require_once("includes/classes/Constants.php");
$account = new Account($con);
if(isset($_POST["submitButton"])){
$firstName = FormSanitizer::sanitizeFormString($_POST["firstName"]);
$lastName = FormSanitizer::sanitizeFormString($_POST["lastName"]);
$username = FormSanitizer::sanitizeFormUsername($_POST["username"]);
$email = FormSanitizer::sanitizeFormEmail($_POST["email"]);
$email2 = FormSanitizer::sanitizeFormEmail($_POST["email2"]);
$password = FormSanitizer::sanitizeFormPassword($_POST["password"]);
$password2 = FormSanitizer::sanitizeFormPassword($_POST["password2"]);
$wasSuccessful = $account->register($firstName, $lastName, $username, $email, $email2, $password, $password2);
if($wasSuccessful){
$_SESSION["userLoggedin"] = $username;
header("Location: index.php");
}
}
function getInputValue($name){
if(isset($_POST[$name])){
echo $_POST[$name];
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>VideoTube</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="assets/css/style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
</head>
<body>
<div class="signInContainer">
<div class="column">
<div class="header">
<img src="assets/images/icons/VideoTubeLogo.png" title="logo" alt="Site Logo">
<h3>Sign Up</h3>
<span>to continue to VideoTube</span>
</div>
<div class="loginForm">
<form action="signup.php" method="POST">
<?php echo $account->getError(Constants::$firstNameCharacters); ?>
<input type="text" name="firstName" value="<?php getInputValue('firstName'); ?>" placeholder="First name" autocomplete="off" required>
<?php echo $account->getError(Constants::$lastNameCharacters); ?>
<input type="text" name="lastName" value="<?php getInputValue('lastName'); ?>" placeholder="Last name" autocomplete="off" required>
<?php echo $account->getError(Constants::$usernameCharacters); ?>
<?php echo $account->getError(Constants::$usernameTaken); ?>
<input type="text" name="username" value="<?php getInputValue('username'); ?>" placeholder="Username" autocomplete="off" required>
<?php echo $account->getError(Constants::$emailsDoNotMatch); ?>
<?php echo $account->getError(Constants::$emailInvalid); ?>
<?php echo $account->getError(Constants::$emailTaken); ?>
<input type="email" name="email" value="<?php getInputValue('email'); ?>" placeholder="Email" autocomplete="off" required>
<input type="email" name="email2" value="<?php getInputValue('email2'); ?>" placeholder="Confirm email" autocomplete="off" required>
<?php echo $account->getError(Constants::$passwordsDoNotMatch); ?>
<?php echo $account->getError(Constants::$passwordNotAlphanumeric); ?>
<?php echo $account->getError(Constants::$passwordLength); ?>
<input type="password" name="password" placeholder="Password" autocomplete="off" required>
<input type="password" name="password2" placeholder="Confirm password" autocomplete="off" required>
<input type="submit" name="submitButton" value="SUBMIT">
</form>
</div>
<a class="signInMessage" href="signin.php">Already have an account? Sign in here!</a>
</div>
</div>
</body>
</html>