<?php
session_start();
$admin_code = '32513252'; // Código de acesso definido

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $input_code = $_POST['access_code'];
    
    if ($input_code === $admin_code) {
        $_SESSION['authenticated'] = true;
        header("Location: update_user.php"); // Redireciona para a página de atualização
        exit();
    } else {
        $error_message = "Código de acesso inválido.";
    }
}
?>

<!DOCTYPE html>
<html lang="pt-BR">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Acesso Administrador</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }
        .container {
            background-color: #fff;
            padding: 20px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            border-radius: 10px;
            width: 300px;
            text-align: center;
        }
        h1 {
            font-size: 24px;
            margin-bottom: 20px;
        }
        input[type="password"] {
            width: 100%;
            padding: 10px;
            margin: 10px 0;
            border: 1px solid #ccc;
            border-radius: 5px;
            font-size: 16px;
        }
        button {
            background-color: #28a745;
            color: #fff;
            padding: 10px 15px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            width: 100%;
        }
        button:hover {
            background-color: #218838;
        }
        .error {
            color: red;
            margin-top: 10px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>ACESSO ADMINISTRADOR</h1>
        <form method="POST" action="">
            <input type="password" id="access_code" name="access_code" placeholder="Digite o código de acesso" required><br>
            <button type="submit">Entrar</button>
        </form>
        <?php if (isset($error_message)) { echo "<p class='error'>$error_message</p>"; } ?>
    </div>
</body>
</html>
