DOCTYPE
DOCTYPE
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
body {
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f4f4f4;
.container {
text-align: center;
background: #fff;
padding: 20px;
border-radius: 8px;
input {
padding: 10px;
margin: 5px 0;
width: 100%;
box-sizing: border-box;
button {
background-color: #007BFF;
color: white;
border: none;
cursor: pointer;
border-radius: 4px;
button:hover {
background-color: #0056b3;
.hidden {
display: none;
</style>
</head>
<body>
<h2>Login</h2>
<input type="text" id="username" placeholder="Username" required />
<button onclick="handleLogin()">Login</button>
</div>
<button onclick="handleLogout()">Logout</button>
</div>
<script src="script.js"></script>
</body>
</html>
function handleLogin() {
localStorage.setItem('isLoggedIn', 'true');
localStorage.setItem('username', username);
// Redirect to homepage
showHomepage();
} else {
function handleLogout() {
localStorage.removeItem('isLoggedIn');
localStorage.removeItem('username');
showLoginPage();
document.getElementById('login-container').classList.add('hidden');
document.getElementById('home-container').classList.remove('hidden');
function showLoginPage() {
document.getElementById('home-container').classList.add('hidden');
document.getElementById('login-container').classList.remove('hidden');
window.onload = function () {
if (isLoggedIn) {
showHomepage();
} else {
showLoginPage();
};
E learning website
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>E-Learning Platform</title>
</head>
<body>
<header>
<nav>
<a href="login.html">Login</a>
<a href="dashboard.html">Dashboard</a>
</nav>
</header>
<main>
</main>
</body>
</html>
login.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login</title>
</head>
<body>
<form id="loginForm">
<button type="submit">Login</button>
</form>
<script src="script.js"></script>
</body>
</html>
dashboard.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dashboard</title>
</head>
<body>
<nav>
<a href="subjects.html">Subjects</a>
<a href="profile.html">Profile</a>
<a href="results.html">Results</a>
</nav>
<script src="script.js"></script>
</body>
</html>
subjects.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Subjects</title>
</head>
<body>
<h2>Select a Subject</h2>
<ul>
<li><a href="course.html?subject=Math">Mathematics</a></li>
<li><a href="course.html?subject=Science">Science</a></li>
</ul>
</body>
</html>
course.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Course Page</title>
</head>
<body>
<h2 id="courseTitle"></h2>
<nav>
<a href="assignments.html">Assignments</a>
<a href="projects.html">Projects</a>
</nav>
<script>
document.getElementById("courseTitle").innerText = new
URLSearchParams(window.location.search).get("subject") + " Course";
</script>
</body>
</html>
quiz.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Quiz</title>
</head>
<body>
<h2>Quiz Section</h2>
<div id="quizContainer"></div>
<script src="script.js"></script>
</body>
</html>
assignments.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Assignments</title>
</head>
<body>
<h2>Assignments</h2>
<button>Submit Assignment</button>
</body>
</html>
script.js
// Simple Authentication
document.getElementById("loginForm")?.addEventListener("submit", function(event) {
event.preventDefault();
localStorage.setItem("authenticated", "true");
window.location.href = "dashboard.html";
} else {
alert("Invalid credentials!");
});
// Logout
function logout() {
localStorage.removeItem("authenticated");
window.location.href = "login.html";
timeLeft--;
if (timeLeft <= 0) {
clearInterval(timer);
}, 1000);