forked from MarvelBoy047/Movie-Mate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Login.html
170 lines (162 loc) · 5.66 KB
/
Login.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Login</title>
<style media="screen">
*, *:before, *:after {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
background-color:black;
font-family: 'Poppins', sans-serif;
color: #ffffff;
overflow: hidden;
}
.background {
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
z-index: -1;
display: flex;
justify-content: space-around;
align-items: center;
}
video {
position: absolute;
width: 100%;
height: 100%;
object-fit: cover;
}
form {
height: 540px;
width: 400px;
background-color: rgba(255, 255, 255, 0.13);
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border-radius: 10px;
backdrop-filter: blur(10px);
border: 2px solid rgba(255, 255, 255, 0.1);
box-shadow: 0 0 40px rgba(8, 7, 16, 0.6);
padding: 50px 35px;
}
form h3 {
font-size: 32px;
font-weight: 500;
line-height: 42px;
text-align: center;
margin-bottom: 20px;
}
label {
display: block;
margin-top: 15px;
font-size: 16px;
font-weight: 500;
}
input {
display: block;
height: 50px;
width: 100%;
background-color: white;
border-radius: 3px;
padding: 0 10px;
margin-top: 8px;
font-size: 14px;
font-weight: 300;
}
::placeholder {
color: #e5e5e5;
}
.Login, .Sign-up {
width: 100%;
background-color: #E50914;
color: #080710 ;
padding: 15px 0;
font-size: 18px;
font-weight: 600;
border-radius: 5px;
cursor: pointer;
margin-top: 30px;
}
.fp {
font-size: 18px;
font-weight: 500;
line-height: 28px;
text-align: center;
margin-top: 20px;
}
.fp a {
color: #23d5ab;
}
</style>
</head>
<body>
<div class="background">
<video autoplay loop muted>
<source src="Background-login\bg.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
<form id="loginForm">
<h3>Login Here</h3>
<label for="username">Username</label>
<input type="text" placeholder="Email or Phone" id="username" required>
<label for="password">Password</label>
<input type="password" placeholder="Password" id="password" required>
<button type="submit" class="Login">Log In</button>
<button type="button" class="Sign-up">New here Sign-up?</button>
<div class="fp">
<a href="login.json">Forgot password?</a>
</div>
<div id="error" style="color: red;"></div> <!-- Error message will be displayed here -->
</form>
<script>
document.addEventListener('DOMContentLoaded', function () {
const loginForm = document.getElementById('loginForm');
const signUpButton = document.querySelector('.Sign-up');
// Handle login form submission
loginForm.addEventListener('submit', function (event) {
event.preventDefault(); // Prevent the form from submitting normally
// Get the entered username and password
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
// Fetch login data from login.json
fetch('login.json')
.then(response => response.json())
.then(data => {
const users = data.users;
// Check if the username exists
const user = users.find(user => user.username === username);
if (!user) {
document.getElementById('error').innerText = "Username not found.";
return;
}
// Check if the password matches
if (user.password !== password) {
document.getElementById('error').innerText = "Incorrect password.";
return;
}
// Login successful
document.getElementById('error').style.color = "green";
document.getElementById('error').innerText = "Login successful!";
// Redirect to index.html after successful login
window.location.href = "main.html";
})
.catch(error => {
console.error('Error fetching login data:', error);
document.getElementById('error').innerText = "Error occurred while logging in. Please try again later.";
});
});
// Redirect to sign-up.html when "New here Sign-up?" button is clicked
signUpButton.addEventListener('click', function () {
window.location.href = "sign-up.html";
});
});
</script>
</body>
</html>