85 lines
2.5 KiB
PHP
85 lines
2.5 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<?php
|
|
echo $_COOKIE['tema'] === 'claro' ? '<link rel="stylesheet" type="text/css" href="estilos_claro.css" />'
|
|
: '<link rel="stylesheet" type="text/css" href="estilos.css" />' ?>
|
|
<title>Perfil de cliente</title>
|
|
</head>
|
|
|
|
<body>
|
|
<?php
|
|
// Leer cookies
|
|
$contador = isset($_COOKIE['contador']) ? $_COOKIE['contador'] : 1;
|
|
setcookie("contador", $contador + 1, 0, "/");
|
|
|
|
session_start();
|
|
$nombre_usuario = $_SESSION['nombre'];
|
|
$tipo_usuario = $_SESSION['tipo'];
|
|
$email_usuario = $_SESSION['email'];
|
|
echo "<div>
|
|
<h2>Bienvenido $nombre_usuario </h2>
|
|
<span>Has visitado la pagina $contador veces.</span> <br>
|
|
<a href=\"logout.php\">Cerrar session</a>
|
|
</div> <br>";
|
|
busqueda($email_usuario);
|
|
|
|
echo "<div>
|
|
<a href=\"formulario_hotel.php\">Registrar reserva</a>
|
|
</div>";
|
|
|
|
|
|
|
|
function busqueda($termBusqueda)
|
|
{
|
|
include_once('caracteres.php');
|
|
$termBusqueda = eliminar_tildes(strtolower($termBusqueda));
|
|
$nombre_archivo = "listado_reservas.txt";
|
|
$registros = [];
|
|
|
|
|
|
$archivo = file_exists($nombre_archivo) ? fopen($nombre_archivo, 'r') : false;
|
|
if ($archivo !== false) {
|
|
while (($linea = fgets($archivo)) !== false) {
|
|
if (strpos(eliminar_tildes(strtolower($linea)), $termBusqueda) !== false) {
|
|
$registros[] = $linea;
|
|
}
|
|
}
|
|
fclose($archivo);
|
|
}
|
|
|
|
if (count($registros) > 0) {
|
|
echo "<table>
|
|
<tbody>
|
|
<thead>
|
|
<th>Id Reserva</th>
|
|
<th>Nombre</th>
|
|
<th>Email</th>
|
|
<th>Nº Telefono</th>
|
|
<th>Fecha de entrada</th>
|
|
<th>Fecha de salida</th>
|
|
<th>Fecha de registro</th>
|
|
<th>Nº de noches</th>
|
|
</thead>";
|
|
foreach ($registros as $registro) {
|
|
$campos = explode("/_/", $registro);
|
|
echo "<tr>";
|
|
foreach ($campos as $campo) {
|
|
echo "<td> $campo </td>";
|
|
}
|
|
echo "</tr>";
|
|
}
|
|
echo "</tbody>";
|
|
echo "</table>";
|
|
} else {
|
|
echo "<div><h4> No se han encontrado registros con los terminos indicados </h4></div>";
|
|
}
|
|
}
|
|
|
|
?>
|
|
</body>
|
|
|
|
</html>
|