38873-vm/login.php
Flatlogic Bot 21f3fc7eab v2
2026-02-28 15:08:46 +00:00

72 lines
3.3 KiB
PHP

<?php
require_once __DIR__ . '/db/config.php';
session_start();
$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'])) {
$_SESSION['user_id'] = $user['id'];
$_SESSION['role'] = $user['role'];
$_SESSION['full_name'] = $user['full_name'];
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;">
<div class="card" style="width: 100%; max-width: 400px;">
<div class="logo" style="text-align: center; margin-bottom: 30px;"><?= htmlspecialchars($platformName) ?></div>
<h2 style="margin-bottom: 10px; text-align: center;">Welcome Back</h2>
<p style="text-align: center; color: var(--text-secondary); margin-bottom: 30px; font-size: 14px;">Log in to access your startup network.</p>
<?php if ($error): ?>
<div style="background: rgba(255, 0, 0, 0.1); border: 1px solid rgba(255, 0, 0, 0.3); color: #ff5555; padding: 12px; border-radius: 8px; margin-bottom: 20px;">
<?= htmlspecialchars($error) ?>
</div>
<?php endif; ?>
<form method="POST">
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500;">Email Address</label>
<input type="email" name="email" required style="width: 100%; padding: 12px; border-radius: 12px; background: var(--surface-color); border: 1px solid var(--border-color); color: #fff;">
</div>
<div style="margin-bottom: 25px;">
<label style="display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500;">Password</label>
<input type="password" name="password" required style="width: 100%; padding: 12px; border-radius: 12px; background: var(--surface-color); border: 1px solid var(--border-color); color: #fff;">
</div>
<button type="submit" class="btn btn-primary" style="width: 100%; padding: 15px;">Log In</button>
<p style="text-align: center; margin-top: 20px; color: var(--text-secondary); font-size: 14px;">Don't have an account? <a href="register.php" style="color: var(--accent-blue);">Sign Up</a></p>
</form>
</div>
</body>
</html>