sesiones
This commit is contained in:
@@ -1,31 +1,45 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="estilos.css" />
|
||||
<title>Busqueda y eliminacion de registros</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<?php
|
||||
session_start();
|
||||
$nombre_usuario = $_SESSION['nombre'];
|
||||
$tipo_usuario = $_SESSION['tipo'];
|
||||
echo "<div>
|
||||
<h2>Bienvenido $nombre_usuario </h2>
|
||||
<a href=\"logout.php\">Cerrar session</a>
|
||||
</div>"
|
||||
?>
|
||||
|
||||
<form method="post">
|
||||
<p>*Término a buscar: </p>
|
||||
<p><input type="text" name="termBusqueda" id="termBusqueda" size="30" placeholder="Introduzca la palabra de Busqueda" required></p>
|
||||
<input type="submit" name="buscar" value="Buscar">
|
||||
<p>*Término a buscar: </p>
|
||||
<p><input type="text" name="termBusqueda" id="termBusqueda" size="30" placeholder="Introduzca la palabra de Busqueda" required></p>
|
||||
<input type="submit" name="buscar" value="Buscar">
|
||||
</form>
|
||||
<br>
|
||||
|
||||
<?php
|
||||
include_once('caracteres.php');
|
||||
|
||||
<?php
|
||||
include_once('caracteres.php');
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['buscar'])) {
|
||||
$termBusqueda = isset($_POST['termBusqueda'])?$_POST['termBusqueda']:'';
|
||||
$termBusqueda!=="" ? busqueda($termBusqueda) : null;
|
||||
$termBusqueda = isset($_POST['termBusqueda']) ? $_POST['termBusqueda'] : '';
|
||||
$termBusqueda !== "" ? busqueda($termBusqueda) : null;
|
||||
unset($_POST);
|
||||
}
|
||||
|
||||
function busqueda($termBusqueda){
|
||||
$termBusqueda=eliminar_tildes(strtolower($termBusqueda));
|
||||
function busqueda($termBusqueda)
|
||||
{
|
||||
$termBusqueda = eliminar_tildes(strtolower($termBusqueda));
|
||||
$nombre_archivo = "listado_reservas.txt";
|
||||
$registros=[];
|
||||
$registros = [];
|
||||
$archivo = fopen($nombre_archivo, 'r');
|
||||
|
||||
while (($linea = fgets($archivo)) !== false) {
|
||||
@@ -35,7 +49,7 @@
|
||||
}
|
||||
fclose($archivo);
|
||||
|
||||
if (count($registros) > 0){
|
||||
if (count($registros) > 0) {
|
||||
echo "<table>
|
||||
<tbody>
|
||||
<thead>
|
||||
@@ -65,75 +79,78 @@
|
||||
}
|
||||
}
|
||||
|
||||
function genButtonDel($idReserva){
|
||||
function genButtonDel($idReserva)
|
||||
{
|
||||
return "<form method=\"POST\" style=\"border: none; padding:0.2rem; min-width: auto; margin:0\">
|
||||
<input type=\"hidden\" name=\"idReserva\" value=\"$idReserva\" style=\"border: none; padding:0; min-width: auto; margin:0\">
|
||||
<input type=\"submit\" name=\"borrar\" value=\"Eliminar\" style=\"border: none; background-color:#5e1622; cursor: pointer; padding:0.2rem 0.4rem; min-width: auto; margin:0\">
|
||||
</form>";
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
<form method="post">
|
||||
<p>*ID de reserva para borrar: </p>
|
||||
<form method="post">
|
||||
<p>*ID de reserva para borrar: </p>
|
||||
<input type="text" name="idReserva" value="" id="idReserva" size="15" minlength="15" maxlength="15" placeholder="Id de reserva" />
|
||||
<input type="submit" name="borrar" value="Borrar reserva de alquiler">
|
||||
</form>
|
||||
<br>
|
||||
<input type="submit" name="borrar" value="Borrar reserva de alquiler">
|
||||
</form>
|
||||
<br>
|
||||
|
||||
<?php
|
||||
<?php
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['borrar'])) {
|
||||
$idReserva = isset($_POST['idReserva'])?$_POST['idReserva']:'';
|
||||
if ($idReserva!==""){
|
||||
$idReserva = isset($_POST['idReserva']) ? $_POST['idReserva'] : '';
|
||||
if ($idReserva !== "") {
|
||||
echo "<div>";
|
||||
echo "<h4>Actuaciones sobre el registro: $idReserva</h4> <br>";
|
||||
echo eliminaDeLista($idReserva) ?
|
||||
"<p>Se ha encontrado el registro en el archivo y se ha eliminado</p>" :
|
||||
"<p>No se encontro el registro especificado en el archivo</p>";
|
||||
"<p>Se ha encontrado el registro en el archivo y se ha eliminado</p>" :
|
||||
"<p>No se encontro el registro especificado en el archivo</p>";
|
||||
echo eliminaRegistro($idReserva) ?
|
||||
"<p>Se ha eliminado correctamente el registro de reserva</p>" :
|
||||
"No se ha encontrado el registro de reserva especificado</p>";
|
||||
"<p>Se ha eliminado correctamente el registro de reserva</p>" :
|
||||
"No se ha encontrado el registro de reserva especificado</p>";
|
||||
echo eliminaUpload($idReserva) ?
|
||||
"<p>Se ha eliminado el documento almacenado con el registro</p>" :
|
||||
"<p>No se ha encontrado documentos asociados al registro</p>";
|
||||
"<p>Se ha eliminado el documento almacenado con el registro</p>" :
|
||||
"<p>No se ha encontrado documentos asociados al registro</p>";
|
||||
echo "</div>";
|
||||
}
|
||||
unset($_POST);
|
||||
}
|
||||
|
||||
function eliminaDeLista($idReserva){
|
||||
function eliminaDeLista($idReserva)
|
||||
{
|
||||
$nombre_archivo = "listado_reservas.txt";
|
||||
$flagEncontrado=false;
|
||||
$registros=[];
|
||||
$flagEncontrado = false;
|
||||
$registros = [];
|
||||
$archivo = fopen($nombre_archivo, 'r');
|
||||
|
||||
while (($linea = fgets($archivo)) !== false) {
|
||||
if (strpos($linea, $idReserva) === false) {
|
||||
$registros[] = $linea;
|
||||
}else{
|
||||
$flagEncontrado=true;
|
||||
} else {
|
||||
$flagEncontrado = true;
|
||||
}
|
||||
}
|
||||
fclose($archivo);
|
||||
return ($flagEncontrado && file_put_contents($nombre_archivo,$registros));
|
||||
return ($flagEncontrado && file_put_contents($nombre_archivo, $registros));
|
||||
}
|
||||
|
||||
function eliminaRegistro($idReserva){
|
||||
$dir_reservas ="reservas/";
|
||||
function eliminaRegistro($idReserva)
|
||||
{
|
||||
$dir_reservas = "reservas/";
|
||||
$nombre_archivo = "$idReserva.txt";
|
||||
return file_exists($dir_reservas.$nombre_archivo) ?
|
||||
unlink($dir_reservas.$nombre_archivo) :
|
||||
false;
|
||||
return file_exists($dir_reservas . $nombre_archivo) ?
|
||||
unlink($dir_reservas . $nombre_archivo) :
|
||||
false;
|
||||
}
|
||||
|
||||
function eliminaUpload($idReserva){
|
||||
$dir_uploads= "dni_clientes/";
|
||||
$file=glob($dir_uploads . "*". $idReserva ."*");
|
||||
function eliminaUpload($idReserva)
|
||||
{
|
||||
$dir_uploads = "dni_clientes/";
|
||||
$file = glob($dir_uploads . "*" . $idReserva . "*");
|
||||
return (count($file) > 0) ? unlink($file[0]) : false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,197 +0,0 @@
|
||||
|
||||
<!Doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>Reservas hotel</title>
|
||||
<link rel="stylesheet" type="text/css" href="estilos.css" />
|
||||
<script>
|
||||
// Función obtener() que realizará la captación de datos,los cálculos y la escritura del mensaje de info
|
||||
|
||||
function obtener() {
|
||||
// Declaro y obtengo el valor de las variables
|
||||
|
||||
//Calcular periodo de la estancia (noches)
|
||||
const inicio=document.getElementById("entradaH").valueAsNumber;
|
||||
const fin=document.getElementById("salida").valueAsNumber;
|
||||
const dif=fin - inicio;
|
||||
const noches=Math.ceil(dif/(1000*60*60*24));
|
||||
document.getElementById("noches").value=noches;
|
||||
|
||||
|
||||
const habitacion=document.getElementById("habitacion").value;
|
||||
const regimen=document.getElementById("regimen").value;
|
||||
const spa=document.getElementById("spa").value;
|
||||
const guia=document.getElementById("guia").value;
|
||||
const nombreCliente=document.getElementById("nombre").value;
|
||||
|
||||
//Cáculo extras (spa y guia)
|
||||
let spaT;
|
||||
|
||||
if (spa>5) {
|
||||
spaT=spa*20;
|
||||
}else {
|
||||
spaT=spa*30;
|
||||
}
|
||||
|
||||
let guiaT;
|
||||
|
||||
if(guia>7) {
|
||||
guiaT=guia*40;
|
||||
} else {
|
||||
guiaT=guia*50;
|
||||
}
|
||||
|
||||
// Tipo habitación
|
||||
let hotel;
|
||||
if (habitacion === "simple") {
|
||||
hotel=50;
|
||||
}
|
||||
|
||||
if (habitacion === "doble") {
|
||||
hotel=80;
|
||||
}
|
||||
|
||||
if (habitacion === "triple") {
|
||||
hotel=120;
|
||||
}
|
||||
|
||||
if (habitacion === "suite") {
|
||||
hotel=150;
|
||||
}
|
||||
|
||||
//Tipo de regimen
|
||||
let comidas;
|
||||
if (regimen === "desayuno") {
|
||||
comidas=50;
|
||||
}
|
||||
|
||||
if (regimen === "mediapension") {
|
||||
comidas=80;
|
||||
}
|
||||
|
||||
if (regimen === "pensioncompleta") {
|
||||
comidas=120;
|
||||
}
|
||||
|
||||
if (regimen === "todoincluido") {
|
||||
comidas=150;
|
||||
}
|
||||
|
||||
// Gastos estancia hotel+comidas
|
||||
const hotelT=hotel*noches;
|
||||
const regimenT=comidas*noches;
|
||||
|
||||
const estancia=hotelT+regimenT;
|
||||
|
||||
// Descuento por larga estancia
|
||||
let estanciaDescuento;
|
||||
if (noches <= 4) {
|
||||
estanciaDescuento = estancia;
|
||||
} else if (noches >= 5 && noches <= 10) {
|
||||
estanciaDescuento = estancia * 0.85;
|
||||
} else if (noches >= 11) {
|
||||
estanciaDescuento = estancia * 0.75;
|
||||
}
|
||||
|
||||
//Envío el precio total sin IVA al formulario
|
||||
document.getElementById("estancia").value=estanciaDescuento;
|
||||
|
||||
//Coste total con extras
|
||||
const total=estanciaDescuento+spaT+guiaT;
|
||||
const totalI=(total*1.21).toFixed(2);
|
||||
// Envío el precio con IVA al formulario
|
||||
document.getElementById("total").value=totalI;
|
||||
// Precio de anulación
|
||||
const precioAnulacion=(total*0.2).toFixed(2);
|
||||
|
||||
|
||||
// Calcular días que faltan y fecha de regreso
|
||||
const hoy=new Date().getTime();// Fecha de la reserva
|
||||
const entrada=document.getElementById("entradaH").valueAsNumber;
|
||||
const dif2=entrada-hoy;
|
||||
const diasFaltan=dif2/(1000*60*60*24);// Días que faltan
|
||||
|
||||
const regresoF=new Date(fin);// Obtener en UTC
|
||||
const regresoP=regresoF.toLocaleDateString();//Pasar fecha a formato corto dd/mm/xxxx
|
||||
|
||||
const anulacion=entrada-(3*24*60*60*1000);//Fecha de anulación
|
||||
const anulacionF=new Date(anulacion);
|
||||
const anulacionP=anulacionF.toLocaleDateString();
|
||||
//Mensaje de información
|
||||
const frase=
|
||||
"Hola "+nombreCliente+"\n"
|
||||
+"Faltan "+(Math.ceil(diasFaltan))+ " días "+"para tu viaje"+"\n"
|
||||
+"Tu fecha de regreso es el "+regresoP+"\n"
|
||||
+"Puedes anular tu reserva hasta el día "+anulacionP+"\n"
|
||||
+"El coste de la anulación será de " +precioAnulacion+ " euros" ;
|
||||
//Enviar mensaje al formulario
|
||||
document.getElementById("info").value=frase;
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
<form action="recibe_formulario_hotel.php" method="post" enctype="multipart/form-data">
|
||||
<h1>Reserve su habitación</h1>
|
||||
<fieldset>
|
||||
<legend>Datos de la reserva</legend>
|
||||
<p><label for="entradaH">Elige la fecha de entrada</label> <input type="date" id="entradaH" name="entrada" value="2024-03-01">
|
||||
<p><label for="salida">Elige la fecha de salida</label> <input type="date" id="salida" name="salida" value="2024-03-10"></p>
|
||||
<p><label for="habitacion">Seleccione el tipo de habitación</label>
|
||||
<!-- Lista de selección -->
|
||||
<select name="habitacion" id="habitacion">
|
||||
<option value="simple">Simple</option>
|
||||
<option value="doble">Doble</option>
|
||||
<option value="triple">Triple</option>
|
||||
<option value="suite">Suite</option>
|
||||
</select></p>
|
||||
<p><label for="regimen">Seleccione el regimen de alojamiento</label>
|
||||
<!-- Lista de selección -->
|
||||
<select name="regimen" id="regimen">
|
||||
<option value="desayuno">Desayuno</option>
|
||||
<option value="mediapension">Media pensión</option>
|
||||
<option value="pensioncompleta">Pensión Completa</option>
|
||||
<option value="todoincluido">Todo Incluido</option>
|
||||
</select></p>
|
||||
<p><label for="estancia">Coste de la estancia (Habitación + Comidas)</label> <input type="text" name="estancia" id="estancia"></p>
|
||||
<p><label for="spa">Acceso al Spa, elija cuantos días</label> <input type="number" name="spa" id="spa" value="0" size="3"></p>
|
||||
|
||||
<p><label for="guia">Servicio de guía turístico, elija cuantos días </label><input type="number" name="guia" id="guia" value="0" size="3"></p>
|
||||
<p><label for="total">Coste total con IVA incluido </label><input type="text" name="total" id="total" ></p>
|
||||
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Datos personales</legend>
|
||||
<p><label for="nombre">*Nombre: </label><input type="text" name="nombre" id="nombre" placeholder="Nombre y Apellidos" required value = "Marcos Lopez Gomez"></p>
|
||||
<p><label for="mail">*Correo electrónico: </label><input type="email" name="email" id="mail" placeholder="Escribe tu correo" required value = "marklogo@gmail.com"></p>
|
||||
<p><label for="telefono">*Teléfono:</label> <input type="tel" id="telefono" name="telefono" required value="649348375" ></p>
|
||||
<p>Check-in online (opcional):</p>
|
||||
<p><label for="dni">DNI:</label> <input type="text" id="dni" name="dni" value="33340763D" ></p>
|
||||
<p><label for="adjuntos">Adjunte fotocopia de DNI </label><input type="file" name="dnifile" id="dnifile" accept=".pdf,.jpg" ></p>
|
||||
<div id="flex">
|
||||
<div>
|
||||
<input type="button" value="Calcular coste total" onclick="obtener()">
|
||||
<br><input type="reset" name="limpiar" value="Borrar" />
|
||||
<br><input type="submit" value="Enviar la reserva" >
|
||||
<input id="noches" name="noches" type="hidden" value="noches">
|
||||
|
||||
</div>
|
||||
<textarea name="info" id="info" >Información de su viaje</textarea>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<br>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
208
Practicas/Practicas_PHP/ejercicios/Plantilla Examen/formulario_hotel.php
Executable file
208
Practicas/Practicas_PHP/ejercicios/Plantilla Examen/formulario_hotel.php
Executable file
@@ -0,0 +1,208 @@
|
||||
<!Doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>Reservas hotel</title>
|
||||
<link rel="stylesheet" type="text/css" href="estilos.css" />
|
||||
<script>
|
||||
// Función obtener() que realizará la captación de datos,los cálculos y la escritura del mensaje de info
|
||||
|
||||
function obtener() {
|
||||
// Declaro y obtengo el valor de las variables
|
||||
|
||||
//Calcular periodo de la estancia (noches)
|
||||
const inicio = document.getElementById("entradaH").valueAsNumber;
|
||||
const fin = document.getElementById("salida").valueAsNumber;
|
||||
const dif = fin - inicio;
|
||||
const noches = Math.ceil(dif / (1000 * 60 * 60 * 24));
|
||||
document.getElementById("noches").value = noches;
|
||||
|
||||
|
||||
const habitacion = document.getElementById("habitacion").value;
|
||||
const regimen = document.getElementById("regimen").value;
|
||||
const spa = document.getElementById("spa").value;
|
||||
const guia = document.getElementById("guia").value;
|
||||
const nombreCliente = document.getElementById("nombre").value;
|
||||
|
||||
//Cáculo extras (spa y guia)
|
||||
let spaT;
|
||||
|
||||
if (spa > 5) {
|
||||
spaT = spa * 20;
|
||||
} else {
|
||||
spaT = spa * 30;
|
||||
}
|
||||
|
||||
let guiaT;
|
||||
|
||||
if (guia > 7) {
|
||||
guiaT = guia * 40;
|
||||
} else {
|
||||
guiaT = guia * 50;
|
||||
}
|
||||
|
||||
// Tipo habitación
|
||||
let hotel;
|
||||
if (habitacion === "simple") {
|
||||
hotel = 50;
|
||||
}
|
||||
|
||||
if (habitacion === "doble") {
|
||||
hotel = 80;
|
||||
}
|
||||
|
||||
if (habitacion === "triple") {
|
||||
hotel = 120;
|
||||
}
|
||||
|
||||
if (habitacion === "suite") {
|
||||
hotel = 150;
|
||||
}
|
||||
|
||||
//Tipo de regimen
|
||||
let comidas;
|
||||
if (regimen === "desayuno") {
|
||||
comidas = 50;
|
||||
}
|
||||
|
||||
if (regimen === "mediapension") {
|
||||
comidas = 80;
|
||||
}
|
||||
|
||||
if (regimen === "pensioncompleta") {
|
||||
comidas = 120;
|
||||
}
|
||||
|
||||
if (regimen === "todoincluido") {
|
||||
comidas = 150;
|
||||
}
|
||||
|
||||
// Gastos estancia hotel+comidas
|
||||
const hotelT = hotel * noches;
|
||||
const regimenT = comidas * noches;
|
||||
|
||||
const estancia = hotelT + regimenT;
|
||||
|
||||
// Descuento por larga estancia
|
||||
let estanciaDescuento;
|
||||
if (noches <= 4) {
|
||||
estanciaDescuento = estancia;
|
||||
} else if (noches >= 5 && noches <= 10) {
|
||||
estanciaDescuento = estancia * 0.85;
|
||||
} else if (noches >= 11) {
|
||||
estanciaDescuento = estancia * 0.75;
|
||||
}
|
||||
|
||||
//Envío el precio total sin IVA al formulario
|
||||
document.getElementById("estancia").value = estanciaDescuento;
|
||||
|
||||
//Coste total con extras
|
||||
const total = estanciaDescuento + spaT + guiaT;
|
||||
const totalI = (total * 1.21).toFixed(2);
|
||||
// Envío el precio con IVA al formulario
|
||||
document.getElementById("total").value = totalI;
|
||||
// Precio de anulación
|
||||
const precioAnulacion = (total * 0.2).toFixed(2);
|
||||
|
||||
|
||||
// Calcular días que faltan y fecha de regreso
|
||||
const hoy = new Date().getTime(); // Fecha de la reserva
|
||||
const entrada = document.getElementById("entradaH").valueAsNumber;
|
||||
const dif2 = entrada - hoy;
|
||||
const diasFaltan = dif2 / (1000 * 60 * 60 * 24); // Días que faltan
|
||||
|
||||
const regresoF = new Date(fin); // Obtener en UTC
|
||||
const regresoP = regresoF.toLocaleDateString(); //Pasar fecha a formato corto dd/mm/xxxx
|
||||
|
||||
const anulacion = entrada - (3 * 24 * 60 * 60 * 1000); //Fecha de anulación
|
||||
const anulacionF = new Date(anulacion);
|
||||
const anulacionP = anulacionF.toLocaleDateString();
|
||||
//Mensaje de información
|
||||
const frase =
|
||||
"Hola " + nombreCliente + "\n" +
|
||||
"Faltan " + (Math.ceil(diasFaltan)) + " días " + "para tu viaje" + "\n" +
|
||||
"Tu fecha de regreso es el " + regresoP + "\n" +
|
||||
"Puedes anular tu reserva hasta el día " + anulacionP + "\n" +
|
||||
"El coste de la anulación será de " + precioAnulacion + " euros";
|
||||
//Enviar mensaje al formulario
|
||||
document.getElementById("info").value = frase;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
session_start();
|
||||
$nombre_usuario = $_SESSION['nombre'];
|
||||
$tipo_usuario = $_SESSION['tipo'];
|
||||
echo "<div>
|
||||
<h2>Bienvenido $nombre_usuario </h2>
|
||||
<a href=\"logout.php\">Cerrar session</a>
|
||||
</div>"
|
||||
?>
|
||||
|
||||
<div id="container">
|
||||
<form action="recibe_formulario_hotel.php" method="post" enctype="multipart/form-data">
|
||||
<h1>Reserve su habitación</h1>
|
||||
<fieldset>
|
||||
<legend>Datos de la reserva</legend>
|
||||
<p><label for="entradaH">Elige la fecha de entrada</label> <input type="date" id="entradaH" name="entrada" value="2024-03-01">
|
||||
<p><label for="salida">Elige la fecha de salida</label> <input type="date" id="salida" name="salida" value="2024-03-10"></p>
|
||||
<p><label for="habitacion">Seleccione el tipo de habitación</label>
|
||||
<!-- Lista de selección -->
|
||||
<select name="habitacion" id="habitacion">
|
||||
<option value="simple">Simple</option>
|
||||
<option value="doble">Doble</option>
|
||||
<option value="triple">Triple</option>
|
||||
<option value="suite">Suite</option>
|
||||
</select>
|
||||
</p>
|
||||
<p><label for="regimen">Seleccione el regimen de alojamiento</label>
|
||||
<!-- Lista de selección -->
|
||||
<select name="regimen" id="regimen">
|
||||
<option value="desayuno">Desayuno</option>
|
||||
<option value="mediapension">Media pensión</option>
|
||||
<option value="pensioncompleta">Pensión Completa</option>
|
||||
<option value="todoincluido">Todo Incluido</option>
|
||||
</select>
|
||||
</p>
|
||||
<p><label for="estancia">Coste de la estancia (Habitación + Comidas)</label> <input type="text" name="estancia" id="estancia"></p>
|
||||
<p><label for="spa">Acceso al Spa, elija cuantos días</label> <input type="number" name="spa" id="spa" value="0" size="3"></p>
|
||||
|
||||
<p><label for="guia">Servicio de guía turístico, elija cuantos días </label><input type="number" name="guia" id="guia" value="0" size="3"></p>
|
||||
<p><label for="total">Coste total con IVA incluido </label><input type="text" name="total" id="total"></p>
|
||||
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Datos personales</legend>
|
||||
<p><label for="nombre">*Nombre: </label><input type="text" name="nombre" id="nombre" placeholder="Nombre y Apellidos" required value="Marcos Lopez Gomez"></p>
|
||||
<p><label for="mail">*Correo electrónico: </label><input type="email" name="email" id="mail" placeholder="Escribe tu correo" required value="marklogo@gmail.com"></p>
|
||||
<p><label for="telefono">*Teléfono:</label> <input type="tel" id="telefono" name="telefono" required value="649348375"></p>
|
||||
<p>Check-in online (opcional):</p>
|
||||
<p><label for="dni">DNI:</label> <input type="text" id="dni" name="dni" value="33340763D"></p>
|
||||
<p><label for="adjuntos">Adjunte fotocopia de DNI </label><input type="file" name="dnifile" id="dnifile" accept=".pdf,.jpg"></p>
|
||||
<div id="flex">
|
||||
<div>
|
||||
<input type="button" value="Calcular coste total" onclick="obtener()">
|
||||
<br><input type="reset" name="limpiar" value="Borrar" />
|
||||
<br><input type="submit" value="Enviar la reserva">
|
||||
<input id="noches" name="noches" type="hidden" value="noches">
|
||||
|
||||
</div>
|
||||
<textarea name="info" id="info">Información de su viaje</textarea>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<br>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,2 @@
|
||||
1709555328_6286/_/Marcos Lopez Gomez/_/marklogo@gmail.com/_/649348375/_/2024-03-08/_/2024-03-21/_/04-03-2024 12:28:48/_/13
|
||||
1709555366_8127/_/Marcos Lopez Gomez/_/marklogo1@gmail.com/_/649348375/_/2024-03-05/_/2024-03-10/_/04-03-2024 12:29:26/_/5
|
||||
@@ -0,0 +1,87 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="estilos.css" />
|
||||
<title>Login</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>
|
||||
<h2>Login de usuario</h2>
|
||||
<form method="post">
|
||||
<p style="display:flex; flex-direction: column; ">
|
||||
<label for="email">Usuario</label>
|
||||
<input type="usuario" name="usuario" placeholder="Usuario" required>
|
||||
</p>
|
||||
<p style="display:flex; flex-direction: column; ">
|
||||
<label for="password">Contraseña</label>
|
||||
<input type="password" name="password" placeholder="Password" required>
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" value="Entrar">
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
<div>
|
||||
<a href="./registro.php?tipo=cliente">Registrarse como cliente</a> <br>
|
||||
<a href="./registro.php?tipo=hotel">Registrarse como personal del hotel</a>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
// Validar si se han enviado los datos del formulario
|
||||
if (isset($_POST["usuario"]) && isset($_POST["password"])) {
|
||||
$usuario = trim($_POST["usuario"]);
|
||||
$password = trim($_POST["password"]);
|
||||
|
||||
// Obtener datos de usuarios registrados
|
||||
$archivo = "usuarios.txt";
|
||||
if (file_exists($archivo)) {
|
||||
$usuarios = file_get_contents($archivo);
|
||||
$lineas = explode("\n", $usuarios);
|
||||
$credenciales_correctas = false;
|
||||
$nombre_usuario = "";
|
||||
$email_usuario = "";
|
||||
$tipo_usuario = "";
|
||||
foreach ($lineas as $linea) {
|
||||
$datos = explode(":", $linea);
|
||||
if (isset($datos[1]) && ($datos[1] == $usuario && password_verify($password, $datos[2]))) {
|
||||
$credenciales_correctas = true;
|
||||
$nombre_usuario = $datos[0];
|
||||
$email_usuario = $datos[1];
|
||||
$tipo_usuario = $datos[3];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($credenciales_correctas) {
|
||||
session_start();
|
||||
$_SESSION['nombre'] = $nombre_usuario;
|
||||
$_SESSION['email'] = $email_usuario;
|
||||
$_SESSION['tipo'] = $tipo_usuario;
|
||||
switch ($tipo_usuario) {
|
||||
case 'hotel':
|
||||
header('Location: busqueda.php');
|
||||
break;
|
||||
case 'cliente':
|
||||
header('Location: perfil_cliente.php');
|
||||
break;
|
||||
}
|
||||
exit();
|
||||
} else {
|
||||
echo "<div> Credenciales incorrectas. Por favor, inténtalo de nuevo. </div>";
|
||||
}
|
||||
} else {
|
||||
echo "<div> No hay usuarios registrados aún. </div>";
|
||||
}
|
||||
} else {
|
||||
echo "<div> Por favor, complete todos los campos. </div>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
session_start();
|
||||
session_destroy();
|
||||
header('Location: login.php');
|
||||
exit();
|
||||
?>
|
||||
@@ -0,0 +1,77 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="estilos.css" />
|
||||
<title>Perfil de cliente</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
$nombre_usuario = $_SESSION['nombre'];
|
||||
$tipo_usuario = $_SESSION['tipo'];
|
||||
$email_usuario = $_SESSION['email'];
|
||||
echo "<div>
|
||||
<h2>Bienvenido $nombre_usuario </h2>
|
||||
<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>
|
||||
@@ -7,8 +7,18 @@
|
||||
<title>Reservas Hotel!!!</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
session_start();
|
||||
$nombre_usuario = $_SESSION['nombre'];
|
||||
$tipo_usuario = $_SESSION['tipo'];
|
||||
echo "<div>
|
||||
<h2>Bienvenido $nombre_usuario </h2>
|
||||
<a href=\"logout.php\">Cerrar session</a>
|
||||
</div>"
|
||||
?>
|
||||
<div>
|
||||
|
||||
|
||||
<?php
|
||||
// Validar el método de solicitud HTTP
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="estilos.css" />
|
||||
<title>Registro de personal de hotel</title>
|
||||
</head>
|
||||
|
||||
|
||||
<?php
|
||||
if ($_SERVER["REQUEST_METHOD"] == "GET") {
|
||||
$tipo_usuario = "";
|
||||
if (!(isset($_GET["tipo"]) && ($_GET["tipo"] === 'cliente' || $_GET["tipo"] === 'hotel'))) {
|
||||
header('Location: login.php');
|
||||
}
|
||||
$tipo_usuario = $_GET["tipo"];
|
||||
}
|
||||
?>
|
||||
|
||||
<body>
|
||||
<div>
|
||||
<h2>Registro
|
||||
<?php
|
||||
echo $tipo_usuario === 'hotel' ? "de personal del hotel" : "de clientes";
|
||||
?>
|
||||
</h2>
|
||||
<form method="post">
|
||||
<p style="display:flex; flex-direction: column; ">
|
||||
<label for="nombre">Nombre:</label>
|
||||
<input type="nombre" name="nombre" placeholder="Nombre" required>
|
||||
</p>
|
||||
<p style="display:flex; flex-direction: column; ">
|
||||
<label for="email">Correo electrónico:</label>
|
||||
<input type="email" name="email" placeholder="Email" required>
|
||||
</p>
|
||||
<p style="display:flex; flex-direction: column; ">
|
||||
<label for="password">Contraseña:</label>
|
||||
<input type="password" name="password" placeholder="Password" required>
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" value="Registrar">
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
// Validar si se han enviado los datos del formulario
|
||||
if (isset($_POST["email"]) && isset($_POST["password"])) {
|
||||
$nombre = trim($_POST["nombre"]);
|
||||
$email = trim($_POST["email"]);
|
||||
$password = password_hash(trim($_POST["password"]),PASSWORD_DEFAULT);
|
||||
$tipo_usuario= trim($_GET["tipo"]);
|
||||
|
||||
// Validar si el archivo de almacenamiento existe, si no, crearlo
|
||||
$archivo = "usuarios.txt";
|
||||
if (!file_exists($archivo)) {
|
||||
fopen($archivo, "w");
|
||||
}
|
||||
|
||||
// Validar si el email ya está registrado
|
||||
$usuarios = file_get_contents($archivo);
|
||||
$lineas = explode("\n", $usuarios);
|
||||
$email_existe = false;
|
||||
foreach ($lineas as $linea) {
|
||||
$datos = explode(":", $linea);
|
||||
if (isset($datos[1]) && ($datos[1] == $email)) {
|
||||
$email_existe = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Si el email no está registrado, almacenarlo en el archivo
|
||||
if (!$email_existe) {
|
||||
$nueva_linea = $nombre . ":" . $email . ":" . $password . ":" . $tipo_usuario . "\n";
|
||||
file_put_contents($archivo, $nueva_linea, FILE_APPEND | LOCK_EX);
|
||||
header('Location: login.php');
|
||||
exit();
|
||||
} else {
|
||||
echo "Este email ya está registrado.";
|
||||
}
|
||||
} else {
|
||||
echo "Por favor, complete todos los campos.";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,14 @@
|
||||
Id reserva: 1709555328_6286
|
||||
Fecha de reserva: 04-03-2024 12:28:48
|
||||
Fecha de entrada: 2024-03-08
|
||||
Fecha de salida: 2024-03-21
|
||||
Tipo de habitación: simple
|
||||
Regimen de alojamiento: desayuno
|
||||
Días Spa: 0
|
||||
Días Guia: 0
|
||||
Duración estancia: 13
|
||||
Coste Total: 1179.75
|
||||
Nombre: Marcos Lopez Gomez
|
||||
Correo electrónico: marklogo@gmail.com
|
||||
Teléfono: 649348375
|
||||
DNI: 33340763D
|
||||
@@ -0,0 +1,14 @@
|
||||
Id reserva: 1709555366_8127
|
||||
Fecha de reserva: 04-03-2024 12:29:26
|
||||
Fecha de entrada: 2024-03-05
|
||||
Fecha de salida: 2024-03-10
|
||||
Tipo de habitación: simple
|
||||
Regimen de alojamiento: desayuno
|
||||
Días Spa: 0
|
||||
Días Guia: 0
|
||||
Duración estancia: 5
|
||||
Coste Total: 514.25
|
||||
Nombre: Marcos Lopez Gomez
|
||||
Correo electrónico: marklogo1@gmail.com
|
||||
Teléfono: 649348375
|
||||
DNI: 33340763D
|
||||
@@ -0,0 +1,2 @@
|
||||
Pablo López Gómez:marklogo@gmail.com:$2y$10$NDc/iJcOFm9EvP3UXKI0PumtcfUe.2VfxfrXR2OXOBScw8pDu.IKa:hotel
|
||||
Marcos Lopez Gomez:marklogo1@gmail.com:$2y$10$yRaUcaYDGod1zRRLizbfi..hEPa8kkZre7Xk83c1pe/W/wXXrj6jW:cliente
|
||||
Reference in New Issue
Block a user