Mini Kabibi Habibi
<?php
session_start();
include 'includes/db.php';
$error = '';
// Redirect if already logged in
if (isset($_SESSION['user'])) {
header("Location: index.php");
exit;
}
// Handle login
if (isset($_POST['login'])) {
$username = trim($_POST['username']);
$password = $_POST['password'];
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = ?");
$stmt->execute([$username]);
$user = $stmt->fetch();
if ($user && password_verify($password, $user['password'])) {
$_SESSION['user'] = $user['username'];
header("Location: index.php");
exit;
} else {
$error = "Invalid username or password!";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>SDO ICT Unit</title>
<style>
body {
font-family: Arial, sans-serif;
background: url('image/background2.jpg') no-repeat center center fixed;
background-size: cover;
display: flex;
height: 100vh;
justify-content: center;
align-items: center;
margin: 0;
}
.login-box {
background: white;
padding: 30px;
box-shadow: 0 0 10px gray;
width: 320px;
border-radius: 5px;
text-align: center;
margin-bottom: 20px;
color: #006400; /* dark green */
}
input[type="text"], input[type="password"] {
width: 100%;
padding: 12px;
margin: 10px 0;
box-sizing: border-box;
}
button {
background: #006400;
color: white;
border: none;
padding: 12px;
width: 100%;
cursor: pointer;
font-size: 16px;
border-radius: 3px;
}
.error {
color: red;
margin-bottom: 10px;
}
.logo {
display: block;
margin: 0 auto 15px auto; /* center + spacing below */
max-width: 120px; /* adjust this size as needed */
height: auto;
}
</style>
</head>
<body>
<div class="login-box">
<img src="image/sdologo.png" alt="SDO Logo" class="logo">
<h2>SDO ICT Unit </h2>
<?php if ($error): ?>
<p class="error"><?= htmlspecialchars($error) ?></p>
<?php endif; ?>
<form method="POST" action="">
<input type="text" name="username" placeholder="Username" required autofocus>
<input type="password" name="password" placeholder="Password" required>
<button type="submit" name="login">Login</button>
</form>
</div>
</body>
</html>