-
Notifications
You must be signed in to change notification settings - Fork 0
/
registration.ejs
186 lines (165 loc) · 4.91 KB
/
registration.ejs
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HabitMaster Registration</title>
<style>
body, html {
height: 100%;
margin: 0;
font-family: 'Courier New', Courier, monospace;
background: linear-gradient(to bottom, #a9e7ff 0%, #ff7ff4 100%);
}
.container {
display: flex;
justify-content: space-between;
align-items: center;
height: 100%;
padding: 0 10%;
}
.login-section, .register-section {
width: 45%;
}
.login-section {
text-align: left;
}
.login-section h1 {
font-family: 'Courier New', Courier, monospace;
font-size: 3em;
margin: 0 0 20px 0;
color: #f1dada;
position: absolute;
top: 35%;
width: 100%;
text-shadow: 0 1px 0 hsl(0,43%,80%),
0 2px 0 hsl(0,43%,75%),
0 3px 0 hsl(0,43%,70%),
0 4px 0 hsl(0,43%,66%),
0 5px 0 hsl(0,43%,64%),
0 6px 0 hsl(0,43%,62%),
0 7px 0 hsl(0,43%,61%),
0 8px 0 hsl(0,43%,60%),
0 0 5px rgba(0,0,0,.05),
0 1px 3px rgba(0,0,0,.2),
0 3px 5px rgba(0,0,0,.2),
0 5px 10px rgba(0,0,0,.2),
0 10px 10px rgba(0,0,0,.2),
0 20px 20px rgba(0,0,0,.2);
}
.register-section {
background: #bcbcbc;
font-size: medium;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
h2 {
font-size: 2em;
text-align: center;
font-family: cursive;
margin: 0 0 20px 0;
color: #914848;
}
p {
color: #555;
font-weight: 300;
}
.back-link {
display: block;
background-color:#474646;
color: #ffffff;
border: none;
padding: 10px 20px;
text-align: center;
text-decoration: none;
font-size: 16px;
margin: 20px 0;
cursor: pointer;
border-radius: 4px;
}
.back-link:hover {
background-color: #ab7e7e;
color: #000;
}
input[type=text], input[type=email], input[type=date], input[type=password] {
width: calc(100% - 20px);
padding: 10px;
margin: 10px 0;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
}
.register-button {
background: #333;
color: white;
font-size: medium;
padding: 10px 20px;
margin: 20px 0;
border: none;
border-radius: 4px;
cursor: pointer;
width: 100%;
}
.register-button:hover {
background: #555;
}
</style>
</head>
<body>
<div class="container">
<div class="login-section">
<h1>HabitMaster</h1>
<p>your daily habit tracker</p>
<button class="back-link" onclick="redirectToLogin()">BACK TO LOGIN</button>
</div>
<div class="register-section">
<h2>REGISTER</h2>
<input type="text" id="usernameInput" placeholder="Username" name="username" required>
<input type="email" id="emailInput" placeholder="Email" name="email" required>
<input type="date" id="dobInput" placeholder="Date of Birth" name="dob" required>
<input type="password" id="passwordInput" placeholder="Password" name="password" required>
<input type="password" id="confirmPasswordInput" placeholder="Confirm Password" name="confirm password" required>
<button class="register-button" onclick="registerUser()">Register</button>
</div>
</div>
<script>
function redirectToLogin() {
window.location.href = '/login';
}
</script>
<script>
async function registerUser() {
const username = document.getElementById('usernameInput').value;
const email = document.getElementById('emailInput').value;
const dob = document.getElementById('dobInput').value;
const password = document.getElementById('passwordInput').value;
const confirmPassword = document.getElementById('confirmPasswordInput').value;
if (password !== confirmPassword) {
alert('Passwords do not match');
return;
}
const response = await fetch('/register', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
username,
email,
dob,
password,
}),
});
if (response.ok) {
const result = await response.json();
console.log(result);
// Optionally, you can redirect to the login page after successful registration
window.location.href = '/login';
} else {
alert('Registration failed');
}
}
</script>
</body>
</html>