35710-vm/login.php
Flatlogic Bot 7a219bcd94 Kotkakey
2025-11-14 10:21:25 +00:00

92 lines
3.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
session_start();
require_once 'db/config.php';
$error_message = '';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['email']) && isset($_POST['password'])) {
$email = $_POST['email'];
$password = $_POST['password'];
try {
$pdo = db();
$stmt = $pdo->prepare("SELECT * FROM users WHERE email = ?");
$stmt->execute([$email]);
$user = $stmt->fetch();
if ($user && password_verify($password, $user['password'])) {
$_SESSION['user_id'] = $user['id'];
header("Location: dashboard.php");
exit;
} else {
$error_message = "Invalid email or password.";
}
} catch (PDOException $e) {
$error_message = "Database error: " . $e->getMessage();
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Kotkakey</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body>
<header class="bg-white shadow-sm">
<nav class="navbar navbar-expand-lg navbar-light">
<div class="container">
<a class="navbar-brand" href="index.php">
<img src="assets/pasted-20251114-095035-cf5716ad.png" alt="Kotkakey Logo" height="40">
</a>
<div class="ms-auto d-flex align-items-center">
<span class="navbar-text me-3">EN / FI</span>
</div>
</div>
</nav>
</header>
<main class="container my-5">
<div class="row justify-content-center">
<div class="col-md-6 col-lg-4">
<div class="card">
<div class="card-body">
<h3 class="card-title text-center mb-4">Login</h3>
<?php if ($error_message): ?>
<div class="alert alert-danger"><?php echo $error_message; ?></div>
<?php endif; ?>
<form action="login.php" method="post">
<div class="mb-3">
<label for="email" class="form-label">Email address</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<button type="submit" class="btn btn-primary w-100">Login</button>
</form>
</div>
</div>
</div>
</div>
</main>
<footer class="py-4 bg-dark text-white mt-auto">
<div class="container text-center">
<p>Email: <a href="mailto:contact@kotkakey.fi" class="text-white">contact@kotkakey.fi</a> | <a href="#" class="text-white">LinkedIn</a></p>
<p><a href="#" class="text-white">Privacy Policy</a> | GDPR Compliant</p>
<small>&copy; <?php echo date("Y"); ?> Kotkakey. All Rights Reserved.</small>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>