<?php
session_start();

// Identifiants (à modifier)
$validUser = "admin";
$validPass = password_hash("1234", PASSWORD_DEFAULT);

if ($_SERVER["REQUEST_METHOD"] === "POST") {
    $user = $_POST["username"];
    $pass = $_POST["password"];

    if ($user === $validUser && password_verify($pass, $validPass)) {
        $_SESSION["loggedin"] = true;
        header("Location: welcome.php");
        exit;
    } else {
        $error = "Identifiants incorrects";
    }
}
?>

<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Home Office</title>
<style>
body {
    font-family: Arial;
    background: url("https://images.unsplash.com/photo-1501785888041-af3ef285b470") no-repeat center center fixed;
    background-size: cover;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}
.box {
    background: rgba(255,255,255,0.9);
    padding: 30px;
    border-radius: 10px;
    text-align: center;
}
input, button {
    width: 100%;
    padding: 10px;
    margin: 8px 0;
}
.error {
    color: red;
}
</style>
</head>
<body>

<div class="box">
    <h2>Home Office</h2>
    <form method="POST">
        <input type="text" name="username" placeholder="Login" required>
        <input type="password" name="password" placeholder="Mot de passe" required>
        <button type="submit">Se connecter</button>
    </form>
    <?php if (!empty($error)) echo "<div class='error'>$error</div>"; ?>
</div>

</body>
</html>