<!-- Dropdown menu -->
<div class="dropdown-menu dropdown-menu-end">
    <a href="#" class="dropdown-item">Profile</a>
    <a href="#" class="dropdown-item">Setting</a>
    <a href="#" class="dropdown-item" onclick="document.getElementById('logout-form').submit();">Logout</a>
</div>

<!-- Hidden form for logout -->
<form id="logout-form" method="POST" action="logo_profile.php">
    <input type="hidden" name="logout" value="1">
</form>

<?php 
include "../database/database.php";
include "../database/data.php";

if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['logout'])) {
    $sql = "SELECT * FROM ".$admin_account." WHERE browser_id='$b_id'";
    $result = $connection->query($sql);
    if ($result && $result->num_rows > 0) {
        while ($row = $result->fetch_assoc()){
            $username = $row['user_name'];

            $sql = "UPDATE ".$admin_account." SET browser_id='0' WHERE user_name='$username'"; //update Browser ID
            $insertResult = $connection->query($sql);
            if ($insertResult) {
                // Perform any additional logout operations here
            } else {
                // Handle error if needed
            }
        }
    }
    // Redirect to the login page or any other appropriate page after logout
    header("Location: admin_login.html");
    exit();
}
?>
