forked from vishal02527/My-Strength-Shree-Krishna
-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.html
164 lines (152 loc) · 4.4 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Discussion Forum - Shree Krishna</title>
<style>
body {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
background-image: url(https://www.hitaambrish.com/stat/img/home/quotes-bg.jpg);
color: #333;
margin: 0;
padding: 0;
box-sizing: border-box;
}
h2::selection,
label::selection {
background-color: rgb(237, 204, 133);
color: #000;
}
main {
padding: 20px;
}
.login-form {
max-width: 400px;
margin: 150px auto 0px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
padding: 20px;
}
h2 {
color: #ab9353;
margin-top: 0;
text-align: center;
}
label {
display: block;
margin-bottom: 8px;
color: #555;
}
input {
width: 93%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 5px;
}
input:focus {
border: 2px solid #ffc107;
outline: 0;
}
.forgot-password {
display: block;
margin-top: 2px;
margin-bottom: 12px;
color: #6b7290;
font-weight: 400;
text-decoration: none;
}
.forgot-password:hover {
color: #3b82f8;
}
button {
display: block;
background: linear-gradient(269deg, #0048ff, #0096ff);
color: #fff;
padding: 10px 20px;
border: 0;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
margin-left: 160px;
}
.signup {
text-align: center;
margin-block: 12px;
}
.signup-link {
color: #6b7290;
font-weight: 500;
text-decoration: none;
}
.signup-link:hover {
color: #3b82f8;
text-decoration: underline;
}
@media (max-width: 768px) {
.login-form {
max-width: 280px;
}
label {
font-size: 14px;
}
.login-form h2 {
font-size: 20px;
}
button {
margin-left: 95px;
}
}
</style>
</head>
<body>
<main>
<div class="login-form" id="loginForm">
<h2>Login</h2>
<form id="form" action="./discussion-forum.html" method="GET">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required />
<label for="password">Password:</label>
<input type="password" id="password" name="password" required />
<a class="forgot-password" href="">Forgot password?</a>
<button>Login</button>
<div class="signup">
Don't have an account?
<a class="signup-link" href="./signup.html">Signup</a>
</div>
<!-- Change the button type to "submit" -->
</form>
</div>
<p style="text-align: center">© All rights reserved 2023</p>
</main>
<script>
document
.getElementById("form")
.addEventListener("submit", function (event) {
// Retrieve stored username and password from localStorage
const storedUsername = localStorage.getItem("username");
const storedPassword = localStorage.getItem("password");
// Get user input
const enteredUsername = document.getElementById("username").value;
const enteredPassword = document.getElementById("password").value;
// Check if the entered username and password match the stored values
if (
enteredUsername === storedUsername &&
enteredPassword === storedPassword
) {
// Successful login - allow the form submission
// Set 'isLoggedIn' to true upon successful login
localStorage.setItem("isLoggedIn", "true");
// Redirect to discussion forum with username
window.location.href = "./discussion-forum.html";
} else {
// Prevent form submission if login fails
event.preventDefault();
alert("Invalid username or password. Please try again.");
}
});
</script>
</body>
</html>