92 lines
3.8 KiB
PHP
92 lines
3.8 KiB
PHP
<?php
|
|
require_once __DIR__ . '/db/config.php';
|
|
session_start();
|
|
|
|
// Redirect if already logged in
|
|
if (isset($_SESSION['user_id'])) {
|
|
header("Location: dashboard.php");
|
|
exit;
|
|
}
|
|
|
|
$error = '';
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$email = trim($_POST['email'] ?? '');
|
|
$password = $_POST['password'] ?? '';
|
|
|
|
if (empty($email) || empty($password)) {
|
|
$error = "Email and password are required.";
|
|
} else {
|
|
$stmt = db()->prepare("SELECT * FROM users WHERE email = ?");
|
|
$stmt->execute([$email]);
|
|
$user = $stmt->fetch();
|
|
|
|
if ($user && password_verify($password, $user['password'])) {
|
|
if ($user['verified'] == 0) {
|
|
$error = "Your account is not verified. Please check your email for the verification link.";
|
|
} else {
|
|
$_SESSION['user_id'] = $user['id'];
|
|
$_SESSION['role'] = $user['role'];
|
|
$_SESSION['full_name'] = $user['full_name'];
|
|
|
|
// Check if onboarding is completed
|
|
if ($user['role'] === 'founder' && $user['onboarding_completed'] == 0) {
|
|
header("Location: founder_onboarding.php");
|
|
} else {
|
|
header("Location: dashboard.php");
|
|
}
|
|
exit;
|
|
}
|
|
} else {
|
|
$error = "Invalid email or password.";
|
|
}
|
|
}
|
|
}
|
|
|
|
$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
|
|
?>
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Log In — <?= htmlspecialchars($platformName) ?></title>
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
</head>
|
|
<body style="display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; background: var(--bg-color);">
|
|
|
|
<div class="card" style="width: 100%; max-width: 400px; padding: 40px;">
|
|
<div style="text-align: center; margin-bottom: 40px;">
|
|
<img src="assets/images/logo.svg" alt="Logo" style="width: 64px; height: 64px; margin-bottom: 16px;">
|
|
<div class="logo-text" style="font-size: 28px; justify-content: center;"><?= htmlspecialchars($platformName) ?></div>
|
|
</div>
|
|
|
|
<h2 style="margin-bottom: 8px; text-align: center; font-size: 24px; font-weight: 800;">Welcome Back</h2>
|
|
<p style="text-align: center; color: var(--text-secondary); margin-bottom: 32px; font-size: 14px;">Log in to access your startup network.</p>
|
|
|
|
<?php if ($error): ?>
|
|
<div style="background: rgba(255, 68, 68, 0.1); border: 1px solid var(--error-color); color: var(--error-color); padding: 12px; border-radius: 8px; margin-bottom: 24px; font-size: 14px; text-align: center; font-weight: 600;">
|
|
<?= htmlspecialchars($error) ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<form method="POST">
|
|
<div style="margin-bottom: 20px;">
|
|
<label>Email Address</label>
|
|
<input type="email" name="email" required placeholder="name@university.edu">
|
|
</div>
|
|
<div style="margin-bottom: 32px;">
|
|
<label>Password</label>
|
|
<input type="password" name="password" required placeholder="••••••••">
|
|
</div>
|
|
<button type="submit" class="btn btn-primary" style="width: 100%; padding: 16px;">Log In</button>
|
|
<p style="text-align: center; margin-top: 24px; color: var(--text-secondary); font-size: 14px;">
|
|
Don't have an account? <a href="register.php" style="color: var(--accent-primary); font-weight: 700;">Sign Up</a>
|
|
</p>
|
|
</form>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|