sesiones
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
// Comprobamos si existe la sesión
|
||||
session_start();
|
||||
if (!isset($_SESSION['usuario'])) {
|
||||
// En caso contrario devolvemos a la página login.php
|
||||
header('Location: login_usuarios.php');
|
||||
die();
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
|
||||
<!Doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Reservas hotel</title>
|
||||
<link rel="stylesheet" type="text/css" href="estilos.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div><!-- Saludamos -->
|
||||
<h1>Bienvenido <?php echo $_SESSION['usuario']; ?></h1>
|
||||
<!-- Botón para cerrar la sesión -->
|
||||
<a href="logout.php">Cerrar sesión</a></div>
|
||||
|
||||
|
||||
<div><h2>Estas son sus reservas:</h2>
|
||||
<?php
|
||||
//Suponiendo que el archivo caracteres.php está en la misma carpeta:
|
||||
include('caracteres.php');
|
||||
|
||||
//Abrir el archivo
|
||||
$archivo = fopen('listado_reservas.txt', 'r');
|
||||
|
||||
//Leer el archivo
|
||||
if (!$archivo) { echo("Error abriendo archivo"); }
|
||||
|
||||
// Abro la tabla
|
||||
echo '<br>';
|
||||
echo '<table border="2">';
|
||||
echo "<tr><th>Id Reserva</th><th>Nombre</th><th>Correo</th><th>Teléfono</th><th>Entrada</th><th>Salida</th><th>Fecha reserva</th><th>Duración</th></tr>";
|
||||
|
||||
//Busco la coincidencia
|
||||
$contador=0;
|
||||
while (($linea = fgets($archivo)) != false) {
|
||||
if(strpos(eliminar_tildes(strtolower($linea)), eliminar_tildes(strtolower($_SESSION['correo']))) !== false){
|
||||
|
||||
// Mostrar la tabla con array
|
||||
$arrayLinea=explode('/_/', $linea);
|
||||
//foreach ($arrayLinea as $dato) {
|
||||
// echo "<td>$dato</td>";
|
||||
//}
|
||||
echo "<tr><td>$arrayLinea[0]</td><td>$arrayLinea[1]</td><td>$arrayLinea[2]</td><td>$arrayLinea[3]</td><td>$arrayLinea[4]</td><td>$arrayLinea[5]</td><td>$arrayLinea[6]</td><td>$arrayLinea[7]</td></tr>";
|
||||
$contador++;
|
||||
}
|
||||
}
|
||||
// Cierrro la tabla
|
||||
echo "</table>";
|
||||
if ($contador == 0) {
|
||||
echo "<p>Usted no tiene reservas</p>";
|
||||
}
|
||||
//cerrar el archivo
|
||||
fclose($archivo);
|
||||
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div><p><a href="formulario_hotel.php">Realize su reserva</a></p></div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user