<?php
include 'db.php';

header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=login_report.xls");

echo "<table border='1'>";
echo "<tr><th>Full Name</th><th>Email</th><th>IP Address</th><th>Login Time</th></tr>";

$result = $conn->query("SELECT fullname, email, ip_address, login_time FROM login_logs ORDER BY id DESC");

while ($row = $result->fetch_assoc()) {
    echo "<tr>
            <td>".htmlspecialchars($row['fullname'])."</td>
            <td>".htmlspecialchars($row['email'])."</td>
            <td>".htmlspecialchars($row['ip_address'])."</td>
            <td>".htmlspecialchars($row['login_time'])."</td>
          </tr>";
}
echo "</table>";
?>
