-
Notifications
You must be signed in to change notification settings - Fork 2
/
signup.html
107 lines (94 loc) · 3.73 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sign Up</title>
<link rel="stylesheet" href="./css files/signup.css">
<link rel="stylesheet" href="footer.css">
<link href="https://fonts.googleapis.com/css2?family=DynaPuff:[email protected]&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Afacad+Flux:[email protected]&family=DynaPuff:[email protected]&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
</head>
<body>
<!-- Navbar -->
<nav class="navbar">
<div class="brand">
<i class="fas fa-utensils"></i> चमmuch
</div>
<ul class="nav-links">
<li><a href="index.html">Home</a></li>
<li><a href="Menu.html">Menu</a></li>
</ul>
</nav>
<div class="signup-container">
<div class="signup-img">
<img src="./images/login.png" alt="Catchy Line">
</div>
<div class="signup-form">
<h2>Sign Up</h2>
<form id="signupForm" action="#">
<div class="input-box">
<i class="fas fa-user"></i>
<input id="username" type="text" placeholder="Username" required>
</div>
<div class="input-box">
<i class="fas fa-envelope"></i>
<input id="email" type="email" placeholder="Email" required>
</div>
<div class="input-box password-box">
<i class="fas fa-lock"></i>
<input type="password" id="password" placeholder="Password" required>
<span class="eye-icon">
<i class="fas fa-eye" id="togglePassword"></i>
</span>
</div>
<div class="input-box password-box">
<i class="fas fa-lock"></i>
<input type="password" id="confirmPassword" placeholder="Confirm Password" required>
<span class="eye-icon">
<i class="fas fa-eye" id="toggleConfirmPassword"></i>
</span>
</div>
<button type="submit" class="btn">Sign Up</button>
<!-- Redirection to login page -->
<div class="login-redirect">
<p>Already have an account? <a href="Login.html">Log in here</a></p>
</div>
</form>
</div>
</div>
<!-- Footer -->
<div id="footer"></div>
<script>
fetch('footer.html')
.then(response => response.text())
.then(data => {
document.getElementById('footer').innerHTML = data;
});
// signup user
document.querySelector("#signupForm").addEventListener("submit", async function (e) {
e.preventDefault();
const username = document.querySelector("#username").value;
const password = document.querySelector("#password").value;
try {
const response = await fetch("http://localhost:3000/signup", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ username, password }),
});
const result = await response.json();
if (response.ok) {
alert(result.message);
window.location.href = "login.html"; // Redirect to login page on success
} else {
alert(result.message);
}
} catch (error) {
alert("Something went wrong. Please try again.");
}
});
</script>
<script defer src="./js files/signup.js"></script>
</body>
</html>