-
Notifications
You must be signed in to change notification settings - Fork 0
/
register.php
150 lines (118 loc) · 4.44 KB
/
register.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
include("includes/config.php");
include("includes/classes/Account.php");
include("includes/classes/Constants.php");
$account = new Account($con);
include("includes/handlers/register-handler.php");
include("includes/handlers/login-handler.php");
function getInputValue($name) {
if(isset($_POST[$name])) {
echo $_POST[$name];
}
}
?>
<html>
<head>
<title>Welcome to Musitunes!</title>
<link rel="stylesheet" type="text/css" href="assets/css/register.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="assets/js/register.js"></script>
</head>
<body>
<?php
if(isset($_POST['registerButton'])) {
echo '<script>
$(document).ready(function() {
$("#loginForm").hide();
$("#registerForm").show();
});
</script>';
}
else {
echo '<script>
$(document).ready(function() {
$("#loginForm").show();
$("#registerForm").hide();
});
</script>';
}
?>
<div id="background">
<div id="loginContainer">
<div id="inputContainer">
<form id="loginForm" action="register.php" method="POST">
<h2>Login to your account</h2>
<p>
<?php echo $account->getError(Constants::$loginFailed); ?>
<label for="loginUsername">Username</label>
<input id="loginUsername" name="loginUsername" type="text" placeholder="e.g. joshpaul" value="<?php getInputValue('loginUsername') ?>" required autocomplete="off">
</p>
<p>
<label for="loginPassword">Password</label>
<input id="loginPassword" name="loginPassword" type="password" placeholder="Your password" required>
</p>
<button type="submit" name="loginButton">LOG IN</button>
<div class="hasAccountText">
<span id="hideLogin">Don't have an account yet? Signup here.</span>
</div>
</form>
<form id="registerForm" action="register.php" method="POST">
<h2>Create your free account</h2>
<p>
<?php echo $account->getError(Constants::$usernameCharacters); ?>
<?php echo $account->getError(Constants::$usernameTaken); ?>
<label for="username">Username</label>
<input id="username" name="username" type="text" placeholder="e.g. joshpaul" value="<?php getInputValue('username') ?>" required>
</p>
<p>
<?php echo $account->getError(Constants::$firstNameCharacters); ?>
<label for="firstName">First name</label>
<input id="firstName" name="firstName" type="text" placeholder="e.g. Josh" value="<?php getInputValue('firstName') ?>" required>
</p>
<p>
<?php echo $account->getError(Constants::$lastNameCharacters); ?>
<label for="lastName">Last name</label>
<input id="lastName" name="lastName" type="text" placeholder="e.g. Paul" value="<?php getInputValue('lastName') ?>" required>
</p>
<p>
<?php echo $account->getError(Constants::$emailsDoNotMatch); ?>
<?php echo $account->getError(Constants::$emailInvalid); ?>
<?php echo $account->getError(Constants::$emailTaken); ?>
<label for="email">Email</label>
<input id="email" name="email" type="email" placeholder="e.g. [email protected]" value="<?php getInputValue('email') ?>" required>
</p>
<p>
<label for="email2">Confirm email</label>
<input id="email2" name="email2" type="email" placeholder="e.g. [email protected]" value="<?php getInputValue('email2') ?>" required>
</p>
<p>
<?php echo $account->getError(Constants::$passwordsDoNoMatch); ?>
<?php echo $account->getError(Constants::$passwordNotAlphanumeric); ?>
<?php echo $account->getError(Constants::$passwordCharacters); ?>
<label for="password">Password</label>
<input id="password" name="password" type="password" placeholder="Your password" required>
</p>
<p>
<label for="password2">Confirm password</label>
<input id="password2" name="password2" type="password" placeholder="Your password" required>
</p>
<button type="submit" name="registerButton">SIGN UP</button>
<div class="hasAccountText">
<span id="hideRegister">Already have an account? Log in here.</span>
</div>
</form>
</div>
<div id="loginText">
<h1>Musitunes</h1>
<h2>Get great music, right now</h2>
<h2>Listen to loads of songs for free</h2>
<ul>
<li>Discover music you'll fall in love with</li>
<li>Create your own playlists</li>
<li>Follow artists to keep up to date</li>
</ul>
</div>
</div>
</div>
</body>
</html>