-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsignup.html
115 lines (101 loc) · 4.31 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
107
108
109
110
111
112
113
114
115
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sign Up - Restitch</title>
<link rel="stylesheet" href="signup.css">
</head>
<body>
<!-- Navbar -->
<div class="navbar">
<h1>ReStitch</h1>
<div>
<a href="index.html">Home</a>
<a href="aboutUs.html">About Us</a>
<a href="login.html">Login</a>
<a href="signup.html">Sign Up</a>
</div>
</div>
<!-- Sign-Up Section -->
<div class="signup-section">
<div class="tagline-left">
<img src="th.jpg" alt="Restitch Tagline">
<h1>Revive. Reuse. Restitch.</h1>
</div>
<div class="signup-right">
<h2>Sign Up</h2>
<form id="signup-form">
<label for="name">Name:</label>
<input type="text" id="name" name="fullName" required placeholder="Enter your full name">
<label for="email">Email:</label>
<input type="email" id="email" name="email" required placeholder="Enter your email">
<label for="password">Password:</label>
<input type="password" id="password" name="password" required placeholder="Make a strong password">
<label for="confirmPassword">Confirm Password:</label>
<input type="password" id="confirmPassword" name="confirmPassword" required placeholder="Confirm your password">
<button type="submit"><a href="DonatorHome.html">Sign Up</a></button>
</form>
<!-- Response message -->
<div id="response-message"></div>
<div class="signup-link">
<p>Already a member? <a href="login.html">Login</a></p>
</div>
</div>
</div>
<!-- Footer Section -->
<div class="footer">
<p>© 2024 Restitch. All Rights Reserved.</p>
<div class="social-media">
<a href="#" class="social-icon"><img src="fb.jpg" alt="Facebook"> Facebook</a>
<a href="#" class="social-icon"><img src="insta.jpg" alt="Instagram"> Instagram</a>
<a href="#" class="social-icon"><img src="in.png" alt="LinkedIn"> LinkedIn</a>
</div>
</div>
<!-- JavaScript to handle form submission -->
<script>
document.getElementById('signup-form').addEventListener('submit', async (event) => {
event.preventDefault(); // Prevent form submission
// Collect form data
const fullName = document.getElementById('name').value;
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;
const confirmPassword = document.getElementById('confirmPassword').value;
// Prepare request payload
const userData = {
fullName,
email,
password,
confirmPassword,
userType: "customer" // Optional userType
};
try {
// Send request to the API
const response = await fetch('http://localhost:3002/api/users', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(userData),
});
const data = await response.json();
// Display server response
const messageBox = document.getElementById('response-message');
if (response.ok) {
messageBox.textContent = data.message;
messageBox.style.color = 'green';
window.location.href = 'store.html';
} else {
messageBox.textContent = data.message || 'Error occurred';
messageBox.style.color = 'red';
}
} catch (error) {
console.error('Error:', error);
const messageBox = document.getElementById('response-message');
messageBox.textContent = 'Something went wrong. Please try again.';
messageBox.style.color = 'red';
}
});
</script>
</body>
</html>