220 lines
7.4 KiB
PHP
220 lines
7.4 KiB
PHP
<?php
|
|
session_start();
|
|
require_once 'db/config.php';
|
|
require_once 'mail/MailService.php';
|
|
|
|
$error = '';
|
|
$success = '';
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['email'])) {
|
|
$email = trim($_POST['email']);
|
|
$password = isset($_POST['password']) ? $_POST['password'] : '';
|
|
|
|
// Admin Login
|
|
// Hardcoded admin credentials (consider a more secure solution)
|
|
if ($email === 'admin@example.com' && $password === 'admin') {
|
|
$_SESSION['user'] = 'admin';
|
|
header('Location: admin.php');
|
|
exit;
|
|
}
|
|
|
|
// Participant Login
|
|
try {
|
|
$stmt = db()->prepare("SELECT * FROM attendees WHERE email = ?");
|
|
$stmt->execute([$email]);
|
|
$attendee = $stmt->fetch();
|
|
|
|
if ($attendee && password_verify($password, $attendee['password'])) {
|
|
$_SESSION['user_id'] = $attendee['id'];
|
|
header('Location: dashboard.php');
|
|
exit;
|
|
} else {
|
|
$error = 'Invalid email or password. Would you like to <a href="register.php" style="color: #bbc8fb; font-weight: 600;">register for the webinar</a>?';
|
|
}
|
|
} catch (PDOException $e) {
|
|
error_log($e->getMessage());
|
|
$error = 'A database error occurred. Please try again later.';
|
|
}
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Login - Webinar Platform</title>
|
|
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
|
|
<style>
|
|
:root {
|
|
--primary-color: #2c4bd1;
|
|
--primary-hover: #1029a0;
|
|
--background-start: #0b2083;
|
|
--background-end: #1029a0;
|
|
--card-background: rgba(9, 24, 47, 0.84);
|
|
--text-color: #f3f9ff;
|
|
--muted-text: #bbc8fb;
|
|
--input-border: rgba(221, 226, 253, 0.18);
|
|
--input-focus-border: #2c4bd1;
|
|
--error-color: #ff8ea0;
|
|
--success-color: #18d1b3;
|
|
}
|
|
* {
|
|
box-sizing: border-box;
|
|
}
|
|
body {
|
|
font-family: 'Roboto', sans-serif;
|
|
background:
|
|
radial-gradient(circle at top left, rgba(221, 226, 253, 0.22), transparent 28%),
|
|
linear-gradient(135deg, var(--background-start) 0%, #1029a0 55%, var(--background-end) 100%);
|
|
color: var(--text-color);
|
|
margin: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
align-items: center;
|
|
min-height: 100vh;
|
|
}
|
|
.logo {
|
|
font-weight: 700;
|
|
font-size: 28px;
|
|
margin-bottom: 1.5rem;
|
|
color: #bbc8fb;
|
|
letter-spacing: 0.02em;
|
|
}
|
|
.login-container {
|
|
width: 100%;
|
|
max-width: 440px;
|
|
padding: 2rem;
|
|
}
|
|
.login-card {
|
|
background-color: var(--card-background);
|
|
border-radius: 22px;
|
|
padding: 2.5rem;
|
|
box-shadow: 0 24px 60px rgba(3, 11, 25, 0.4);
|
|
border: 1px solid var(--input-border);
|
|
backdrop-filter: blur(16px);
|
|
}
|
|
h1 {
|
|
font-size: 28px;
|
|
font-weight: 700;
|
|
margin-top: 0;
|
|
margin-bottom: 0.5rem;
|
|
text-align: center;
|
|
}
|
|
.subtitle {
|
|
text-align: center;
|
|
margin-bottom: 2rem;
|
|
color: var(--muted-text);
|
|
}
|
|
.form-group {
|
|
margin-bottom: 1.25rem;
|
|
}
|
|
label {
|
|
display: block;
|
|
margin-bottom: 0.5rem;
|
|
font-weight: 500;
|
|
font-size: 14px;
|
|
color: var(--text-color);
|
|
}
|
|
input[type="email"], input[type="password"] {
|
|
width: 100%;
|
|
padding: 13px 14px;
|
|
border: 1px solid var(--input-border);
|
|
border-radius: 12px;
|
|
box-sizing: border-box;
|
|
font-size: 16px;
|
|
transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
|
|
background: rgba(221, 226, 253, 0.08);
|
|
color: var(--text-color);
|
|
}
|
|
input[type="email"]::placeholder, input[type="password"]::placeholder {
|
|
color: var(--muted-text);
|
|
}
|
|
input[type="email"]:focus, input[type="password"]:focus {
|
|
outline: none;
|
|
border-color: var(--input-focus-border);
|
|
box-shadow: 0 0 0 3px rgba(187, 200, 251, 0.18);
|
|
background: rgba(221, 226, 253, 0.10);
|
|
}
|
|
.submit-button {
|
|
width: 100%;
|
|
padding: 14px;
|
|
border: none;
|
|
background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
|
|
color: white;
|
|
font-weight: 700;
|
|
font-size: 16px;
|
|
border-radius: 12px;
|
|
cursor: pointer;
|
|
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
|
box-shadow: 0 16px 30px rgba(19, 105, 179, 0.32);
|
|
}
|
|
.submit-button:hover {
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 20px 34px rgba(19, 105, 179, 0.38);
|
|
}
|
|
.message {
|
|
padding: 1rem;
|
|
margin-bottom: 1.5rem;
|
|
border-radius: 12px;
|
|
text-align: center;
|
|
font-size: 14px;
|
|
}
|
|
.error {
|
|
background-color: rgba(255, 142, 160, 0.12);
|
|
color: #ffdbe2;
|
|
border: 1px solid rgba(255, 142, 160, 0.34);
|
|
}
|
|
.success {
|
|
background-color: rgba(24, 209, 179, 0.12);
|
|
color: #dcfff8;
|
|
border: 1px solid rgba(24, 209, 179, 0.34);
|
|
}
|
|
.footer-link {
|
|
text-align: center;
|
|
margin-top: 1.5rem;
|
|
font-size: 14px;
|
|
color: var(--muted-text);
|
|
}
|
|
.footer-link a {
|
|
color: var(--primary-color);
|
|
text-decoration: none;
|
|
font-weight: 500;
|
|
}
|
|
.footer-link a:hover {
|
|
text-decoration: underline;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="login-container">
|
|
<div class="logo">WebinarPlatform</div>
|
|
<div class="login-card">
|
|
<h1>Welcome Back</h1>
|
|
<p class="subtitle">Login to access your dashboard</p>
|
|
|
|
<?php if ($error): ?><div class="message error"><?= $error ?></div><?php endif; ?>
|
|
<?php if ($success): ?><div class="message success"><?= $success ?></div><?php endif; ?>
|
|
|
|
<form method="POST" action="login.php">
|
|
<div class="form-group">
|
|
<label for="email">Email Address</label>
|
|
<input type="email" id="email" name="email" required value="<?= isset($_POST['email']) ? htmlspecialchars($_POST['email']) : '' ?>">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="password">Password</label>
|
|
<input type="password" id="password" name="password" required>
|
|
</div>
|
|
<button type="submit" class="submit-button">Login</button>
|
|
</form>
|
|
|
|
<div class="footer-link">
|
|
Don't have an account? <a href="register.php">Register for the Webinar</a>
|
|
</div>
|
|
</div>
|
|
<div class="footer-link" style="margin-top: 2rem;">
|
|
<a href="index.php">← Back to Home</a>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|