This repository has been archived by the owner on Dec 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.html
63 lines (59 loc) · 2.18 KB
/
signup.html
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Sign Up Page</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin="anonymous">
<link href="assets/css/main.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body class="text-center">
<form class="form-signin">
<h1 class="h3 mb-3 font-weight-normal">Sign Up</h1>
<label for="email" class="sr-only">Email address</label>
<input type="email" id="email" class="form-control" placeholder="Email address" required autofocus>
<label for="password" class="sr-only">Password</label>
<input type="password" id="password" class="form-control" placeholder="Password" required>
<label for="name" class="sr-only">Name</label>
<input type="text" id="name" class="form-control" placeholder="Name" required>
<a class="btn btn-lg btn-primary btn-block" onClick="signUp()">Sign up</a>
<a href="/index.html">Already have an account? Login here.</a>
</form>
<script>
function signUp() {
var data = {
email: document.forms[0].elements[0].value,
password: document.forms[0].elements[1].value,
name: document.forms[0].elements[2].value
};
$.ajax({
type: 'POST',
url: '/signup',
data,
// On sucess, sign the user in
success: function (data) {
window.alert('user created successfully.');
$.ajax({
type: 'POST',
url: '/login',
data,
success: function (data) {
window.location.replace('/game.html');
},
error: function (xhr) {
window.alert(JSON.stringify(xhr));
window.location.replace('/index.html');
}
});
},
error: function (xhr) {
window.alert(JSON.stringify(xhr));
window.location.replace('/signup.html');
}
});
}
</script>
</body>
</html>