-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
114 lines (100 loc) · 3.98 KB
/
index.php
File metadata and controls
114 lines (100 loc) · 3.98 KB
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
<?php
require_once 'includes/auth.php';
require_once 'includes/functions.php';
// If user is already logged in, redirect to dashboard
if ($auth->isLoggedIn()) {
redirect('/dashboard.php');
}
$message = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$action = $_POST['action'] ?? '';
if ($action === 'login') {
$username = sanitizeInput($_POST['username'] ?? '');
$password = $_POST['password'] ?? '';
$result = $auth->login($username, $password);
if ($result['success']) {
redirect('/dashboard.php');
} else {
$message = $result['message'];
}
} elseif ($action === 'register') {
$username = sanitizeInput($_POST['username'] ?? '');
$email = sanitizeInput($_POST['email'] ?? '');
$password = $_POST['password'] ?? '';
$full_name = sanitizeInput($_POST['full_name'] ?? '');
$role = sanitizeInput($_POST['role'] ?? 'student');
$result = $auth->register($username, $email, $password, $full_name, $role);
$message = $result['message'];
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>E-Learning Virtual Classroom</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
body {
font-family: 'Inter', sans-serif;
background-color: #f0f8ff;
background-image: url('images/classes.jpg');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed;
min-height: 100vh;
}
/* Add an overlay to improve readability */
.overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
</style>
</head>
<body class="relative">
<!-- Background overlay for better readability -->
<div class="overlay"></div>
<!-- Simple Header -->
<header class="bg-white border-b">
<div class="max-w-4xl mx-auto px-4 py-4">
<div class="flex justify-between items-center">
<h1 class="text-xl font-semibold text-gray-800">E-Learning Virtual Classroom</h1>
</div>
</div>
</header>
<div class="max-w-md mx-auto px-4 py-8 relative z-10">
<!-- Message Display -->
<?php if(!empty($message)): ?>
<div class="mb-6 p-3 rounded text-sm bg-red-100 text-red-700">
<?php echo htmlspecialchars($message); ?>
</div>
<?php endif; ?>
<!-- Login Form -->
<div class="bg-white rounded-lg border p-6 shadow-lg">
<h2 class="text-lg font-medium text-gray-800 mb-4">Login to Your Account</h2>
<form method="POST">
<input type="hidden" name="action" value="login">
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-1">Username or Email</label>
<input type="text" name="username" required
class="w-full px-3 py-2 border border-gray-300 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
</div>
<div class="mb-6">
<label class="block text-sm font-medium text-gray-700 mb-1">Password</label>
<input type="password" name="password" required
class="w-full px-3 py-2 border border-gray-300 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
</div>
<button type="submit" class="w-full bg-blue-600 text-white py-2 rounded text-sm font-medium hover:bg-blue-700 transition duration-200">
Sign In
</button>
</form>
</div>
</div>
</body>
</html>