-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.php
86 lines (76 loc) · 4 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
<?php
require 'include/config.php';
require 'include/classes/Constants.php';
require 'include/classes/FormValidation.php';
require 'include/classes/Account.php';
$account = new Account($conn);
$validate = new FormValidation();
if (isset($_POST['submit'])){
$fname = FormValidation::sanitizeFormString($_POST['fname']);
$lname = FormValidation::sanitizeFormString($_POST['lname']);
$username = FormValidation::sanitizeFormUsername($_POST['username']);
$email = FormValidation::sanitizeFormEmail($_POST['email']);
$pass = FormValidation::sanitizeFormPassword($_POST['pass']);
$cpass = FormValidation::sanitizeFormPassword($_POST['cpass']);
$isSuccessful = $account->register($fname, $lname, $username, $email, $pass, $cpass);
if($isSuccessful){
//success
//redirect to index page
$_SESSION['username'] = $username;
header('location: index.php');
}else{
echo "Failed";
}
}
function getValue($name){
if (isset($_POST[$name])){
echo $_POST[$name];
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>You Pipe</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
<link rel="stylesheet" href="./assets/css/style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.3/dist/umd/popper.min.js" integrity="sha384-eMNCOe7tC1doHpGoWe/6oMVemdAVTMs2xqW4mwXrXsW0L84Iytr2wi5v2QjrP/xp" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.min.js" integrity="sha384-cn7l7gDp0eyniUwwAZgrzD06kc/tftFf19TOAs2zVinnD/C7E91j9yyk5//jjpt/" crossorigin="anonymous"></script>
<script src="./assets/js/commonAction.js"></script>
</head>
<body>
<div class="signInContainer">
<div class="column">
<div class="header">
<img src="./assets/images/icons/youpipe.png" alt="Site logo" title="logo">
<h3>Sign Up</h3>
<span>to continue to VideoPipe</span>
</div>
<div class="logInForm">
<form action="signup.php" method="post">
<?php echo $account->getError(Constants::$firstNameCharacters)?>
<input type="text" name="fname" placeholder="First Name" value="<?php getValue('fname'); ?>" autocomplete="off" required>
<?php echo $account->getError(Constants::$lastNameCharacters)?>
<input type="text" name="lname" placeholder="Last Name" value="<?php getValue('lname'); ?>" autocomplete="off" required>
<?php echo $account->getError(Constants::$usernameTaken)?>
<?php echo $account->getError(Constants::$usernameCharacters)?>
<input type="text" name="username" placeholder="Username" value="<?php getValue('username'); ?>" autocomplete="off" required>
<?php echo $account->getError(Constants::$invalidEmail)?>
<?php echo $account->getError(Constants::$emailTaken)?>
<input type="email" name="email" placeholder="Email" value="<?php getValue('email'); ?>" autocomplete="off" required>
<input type="password" name="pass" placeholder="Password" autocomplete="off" required>
<?php echo $account->getError(Constants::$passwordNotMatch)?>
<?php echo $account->getError(Constants::$passwordCharacter)?>
<input type="password" name="cpass" placeholder="Confirm Password" autocomplete="off" required>
<input type="submit" name="submit" value="SUBMIT">
</form>
</div>
<a class="signInMessage" href="signin.php">Already have an account ? Sign in here!</a>
</div>
</div>
</body>
</html>