This repository has been archived by the owner on Jul 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathsignUp.php
130 lines (104 loc) · 5.28 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
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
<?php
require_once("includes/config.php");
require_once("includes/classes/Account.php");
require_once("includes/classes/Constants.php");
require_once("includes/classes/FormSanitizer.php");
$account = new Account($conn);
if(isset($_POST["submitButton"])){
//firstName & lastName
$firstName = FormSanitizer::sanitizingFormString($_POST["firstName"]);
$lastName = FormSanitizer::sanitizingFormString($_POST["lastName"]);
//Username
$username = FormSanitizer::sanitizingFormUser($_POST["username"]);
//emails
$email = FormSanitizer::sanitizingFormEmail($_POST["email"]);
$email2 = FormSanitizer::sanitizingFormEmail($_POST["email2"]);
//password
$password = FormSanitizer::sanitizingFormPassword($_POST["password"]);
$password2 = FormSanitizer::sanitizingFormPassword($_POST["password2"]);
$wasSuccessful = $account->register($firstName, $lastName, $username, $email, $email2, $password, $password2);
if($wasSuccessful){
$_SESSION["userLoggedIn"] = $username;
header("Location: index.php");
}
else{
echo "login failed";
}
}
function getInputValues($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">
<title>VideoTube</title>
<!-- favicon -->
<link href="assets/images/icons/favicon2.jpg" rel="icon">
<!-- Bootstrap CDN -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<!-- Custom CSS -->
<link rel="stylesheet" href="./assets/CSS/style.css">
<!-- Jquery CDN-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net</br>pm/popper.js@1.16.0/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous">
</script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"
integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous">
</script>
</head>
<body>
<div class="signInContainer">
<div class="column">
<div class="header">
<img src="./assets/images/icons/VideoTubeLogo.png" title="VideoTube home" alt="site-logo">
<h3>Sign Up</h3>
<span>to continue to VideoTube</span>
</div>
<div class="loginForm">
<form action="signUp.php" method="POST">
<!-- displaying error message if any -->
<?php
echo $account->getError(Constants::$firstNameCharacter);
?>
<input type="text" name="firstName" placeholder="first name" autocomplete='off' value="<?php getInputValues('firstName') ?>" required>
<!-- displaying error message if any -->
<?php
echo $account->getError(Constants::$lastNameCharacter);
?>
<input type="text" name="lastName" placeholder="last name" autocomplete='off' value="<?php getInputValues('lastName') ?>" required>
<!-- displaying error message if any -->
<?php
echo $account->getError(Constants::$usernameCharacter);
echo $account->getError(Constants::$usernameTaken);
?>
<input type="text" name="username" placeholder="User name" autocomplete='off' value="<?php getInputValues('username') ?>" required>
<!-- displaying error message if any -->
<?php
echo $account->getError(Constants::$emailDoNotMatch);
echo $account->getError(Constants::$emailTaken);
?>
<input type="email" name="email" placeholder="email" autocomplete='off' value="<?php getInputValues('email') ?>" required>
<input type="email" name="email2" placeholder="confirm email" autocomplete='off' value="<?php getInputValues('email2') ?>" required>
<!-- displaying error message if any -->
<?php
echo $account->getError(Constants::$passwordDoNotMatch);
echo $account->getError(Constants::$passwordNotAlphaNumeric);
echo $account->getError(Constants::$passwordLength);
?>
<input type="password" name="password" placeholder="password" autocomplete='off' required>
<input type="password" name="password2" placeholder="password" autocomplete='off' required>
<input type="submit" class="btn btn-primary" name="submitButton" value="SUBMIT">
</form>
</div>
<a href="signIn.php" class="loginMessage">Already have an account? Sign in here!</a>
</div>
</div>
</body>
</html>