<?php
include("connection.php");
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=usuarios_vpn_".date('Y-m-d').".xls");
$con = connection();
$sql = "SELECT * FROM uservpn ORDER BY id DESC";
$query = $con->query($sql);
echo "<table border='1'>";
echo "<tr>
<th>ID</th>
<th>Nombre</th>
<th>Usuario</th>
<th>Contraseña</th>
<th>Área</th>
<th>Correo</th>
<th>Estado</th>
</tr>";
while ($row = $query->fetch_assoc()) {
echo "<tr>
<td>".$row['id']."</td>
<td>".htmlspecialchars($row['nombre'])."</td>
<td>".htmlspecialchars($row['user'])."</td>
<td>".htmlspecialchars($row['contrasena'])."</td>
<td>".htmlspecialchars($row['area'])."</td>
<td>".htmlspecialchars($row['correo'])."</td>
<td>".htmlspecialchars($row['estado'])."</td>
</tr>";
}
echo "</table>";
?>