PHP
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<form action="" method="POST">
|
||||
<h2>Buqueda de cliente</h2>
|
||||
<div style="display: flex; flex-direction:column; width:fit-content; gap: 0.5rem;">
|
||||
<div style="display: flex; flex-direction:column;">
|
||||
<label for="matricula">Matricula</label>
|
||||
<input type="text" name="matricula" id="matricula">
|
||||
</div>
|
||||
<div style="display: flex; flex-direction:column;">
|
||||
<label for="telefono">Telefono</label>
|
||||
<input type="text" name="telefono" id="telefono">
|
||||
</div>
|
||||
<div style="display: flex; flex-direction:column;">
|
||||
<label for="email">Email</label>
|
||||
<input type="email" name="email" id="email">
|
||||
</div>
|
||||
<div style="display: flex; flex-direction:column; margin-bottom: 1rem;">
|
||||
<label for="Id Usuario">Id Usuario</label>
|
||||
<input type="text" name="idUsuario" id="idUsuario">
|
||||
</div>
|
||||
|
||||
<input type="submit" value="Buscar">
|
||||
</div>
|
||||
<br>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
|
||||
$directorioSeguros = "seguros";
|
||||
$terminoBusqueda = "";
|
||||
if (isset($_POST['matricula'])) {
|
||||
$terminoBusqueda = $_POST['matricula'];
|
||||
} elseif (isset($_POST['telefono'])) {
|
||||
$terminoBusqueda = $_POST['telefono'];
|
||||
} elseif (isset($_POST['email'])) {
|
||||
$terminoBusqueda = $_POST['email'];
|
||||
} elseif (isset($_POST['idUsuario'])) {
|
||||
$terminoBusqueda = $_POST['idUsuario'];
|
||||
}
|
||||
|
||||
$separador = "/_/";
|
||||
$nombre_archivo = "listado_clientes.txt";
|
||||
$archivo = fopen($nombre_archivo, 'r');
|
||||
|
||||
$matriculas = [];
|
||||
while (($linea = fgets($archivo)) !== false) {
|
||||
if (strpos($linea, $terminoBusqueda) !== false) {
|
||||
$matriculas[] = trim(explode("/_/", $linea)[4]);
|
||||
}
|
||||
}
|
||||
fclose($archivo);
|
||||
|
||||
foreach ($matriculas as $matricula) {
|
||||
$archivo = "$matricula" . "_fichacliente.txt";
|
||||
$contenido = file_get_contents($directorioSeguros . '/' . $archivo);
|
||||
echo implode("<br>", explode("\n", $contenido)); // o echo nl2br($contenido);
|
||||
echo "<br><br>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user