-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
52 lines (44 loc) · 1.64 KB
/
script.js
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
// script.js
document.getElementById("loginForm").addEventListener("submit", function (event) {
event.preventDefault();
// Get form values
const username = document.getElementById("username").value.trim();
const password = document.getElementById("password").value.trim();
const role = document.getElementById("role").value;
// Hardcoded credentials
const adminCredentials = { username: "admin", password: "admin@1" };
const teacherCredentials = [
{ username: "teacher1", password: "teacher@1" },
{ username: "teacher2", password: "teacher@2" },
// Add more teachers here if needed
];
const studentCredentials = [
{ username: "student1", password: "student@1" },
{ username: "student2", password: "student@2" },
// Add more students here if needed
];
// Validate credentials
if (
role === "admin" &&
username === adminCredentials.username &&
password === adminCredentials.password
) {
window.location.href = "admin-dashboard.html";
} else if (
role === "teacher" &&
teacherCredentials.some(
(teacher) => teacher.username === username && teacher.password === password
)
) {
window.location.href = "teacher-dashboard.html";
} else if (
role === "student" &&
studentCredentials.some(
(student) => student.username === username && student.password === password
)
) {
window.location.href = "student-dashboard.html";
} else {
alert("Invalid username, password, or role. Please try again!");
}
});