nuevo sistema de busqueda

parent c8387b85
...@@ -59,6 +59,7 @@ session_start(); ...@@ -59,6 +59,7 @@ session_start();
<form action="insertar.php" method="post"> <form action="insertar.php" method="post">
<input type="hidden" name="escuela" value="<?= $_SESSION["escuela"] ?>"> <input type="hidden" name="escuela" value="<?= $_SESSION["escuela"] ?>">
<input type="hidden" name="idioma" value="<?= $_POST['idioma']; ?>"> <input type="hidden" name="idioma" value="<?= $_POST['idioma']; ?>">
<input type="hidden" name="clave_escuela" value="<?= $_POST['clave_escuela']; ?>">
<div class="input-group mb-3"> <div class="input-group mb-3">
<div class="input-group-append"> <div class="input-group-append">
<span class="input-group-text"><i class="fas fa-user"></i></span> <span class="input-group-text"><i class="fas fa-user"></i></span>
......
...@@ -52,14 +52,14 @@ ...@@ -52,14 +52,14 @@
</div> </div>
<div class=" justify-content-center container form_container"> <div class=" justify-content-center container form_container">
<form method="post" action="lenguaje.php"> <form method="get" action="lenguaje.php">
<div class="input-group" id="search-div"> <div class="input-group" id="search-div">
<div class="input-group-append"> <div class="input-group-append">
<span class="input-group-text"><i class="fas fa-search"></i></span> <span class="input-group-text"><i class="fas fa-search"></i></span>
</div> </div>
<input type="text" autocomplete="off" name="escuela" id="search-box" <input type="text" autocomplete="off" id="search-box"
class="form-control col-md-12 custom-select" value="" class="form-control col-md-12 custom-select" value=""
placeholder="Seleccione la clave o nombre de su escuela" required "> placeholder="Seleccione la clave o nombre de su escuela" required ">
<input type="hidden" name="clave_escuela" id="clave_escuela"> <input type="hidden" name="clave_escuela" id="clave_escuela">
......
...@@ -16,7 +16,7 @@ $nombre = str_replace("'","''",$_POST['nombre']); ...@@ -16,7 +16,7 @@ $nombre = str_replace("'","''",$_POST['nombre']);
$comentario = str_replace("'","''",$_POST['comentario']); $comentario = str_replace("'","''",$_POST['comentario']);
$edad = (int)preg_replace("/[^0-9]/", '', $_POST['edad']); $edad = (int)preg_replace("/[^0-9]/", '', $_POST['edad']);
$sql = "INSERT INTO `respuesta`(`id_respuesta`, `clave_escuela`, `idioma`, `nombre`, `edad`, `comentario`, `fecha`, `REMOTE_ADDR`, `HTTP_USER_AGENT`, `latitude`, `longitude`) VALUES (null ,'".$_SESSION['clave_escuela']."','".$_POST['idioma']."','".$nombre."',".$edad.",'".$comentario."', CURRENT_TIMESTAMP,'".$_SERVER['REMOTE_ADDR']."','".$_SERVER['HTTP_USER_AGENT']."','".$_SESSION["latitude"]."','".$_SESSION["longitude"]."')"; $sql = "INSERT INTO `respuesta`(`id_respuesta`, `clave_escuela`, `idioma`, `nombre`, `edad`, `comentario`, `fecha`, `REMOTE_ADDR`, `HTTP_USER_AGENT`, `latitude`, `longitude`) VALUES (null ,'".$_POST['clave_escuela']."','".$_POST['idioma']."','".$nombre."',".$edad.",'".$comentario."', CURRENT_TIMESTAMP,'".$_SERVER['REMOTE_ADDR']."','".$_SERVER['HTTP_USER_AGENT']."','".$_SESSION["latitude"]."','".$_SESSION["longitude"]."')";
if ($conn->query($sql) === TRUE) { if ($conn->query($sql) === TRUE) {
echo "New record created successfully"; echo "New record created successfully";
...@@ -28,6 +28,6 @@ $conn->close(); ...@@ -28,6 +28,6 @@ $conn->close();
header('Location: salida.php?idioma='.$_POST['idioma']); header('Location: salida.php?idioma='.$_POST['idioma']."&clave_escuela=".$_POST['clave_escuela']);
exit; exit;
?> ?>
...@@ -6,58 +6,30 @@ ...@@ -6,58 +6,30 @@
session_start(); session_start();
include "conexion.php"; include "conexion.php";
if (isset($_POST['clave_escuela'])) { $nombre_escuela = "";
$_SESSION["escuela"] = $_POST['escuela']; $clave_escuela = "";
$_SESSION["clave_escuela"] = $_POST['clave_escuela']; $sql = "SELECT e.NOMBRECT, e.CV_CCT FROM Superior e WHERE e.CV_CCT ='" . $_GET['clave_escuela'] . "' GROUP BY e.CV_CCT
$_SESSION["latitude"] = ""; UNION
$_SESSION["longitude"] = ""; SELECT e.NOMBRECT, e.CV_CCT FROM Media e WHERE e.CV_CCT ='" . $_GET['clave_escuela'] . "' GROUP BY e.CV_CCT
} UNION
SELECT e.NOMBRECT, e.CV_CCT FROM Inicial e WHERE e.CV_CCT ='" . $_GET['clave_escuela'] . "' GROUP BY e.CV_CCT
$sql = 'SELECT * FROM Inicial WHERE CV_CCT ="' . $_SESSION['clave_escuela'] . '"'; UNION
SELECT e.NOMBRECT, e.CV_CCT FROM Preescolar e WHERE e.CV_CCT ='" . $_GET['clave_escuela'] . "' GROUP BY e.CV_CCT
UNION
SELECT e.NOMBRECT, e.CV_CCT FROM Primaria e WHERE e.CV_CCT ='" . $_GET['clave_escuela'] . "' GROUP BY e.CV_CCT
UNION
SELECT e.NOMBRECT, e.CV_CCT FROM Secundaria e WHERE e.CV_CCT ='" . $_GET['clave_escuela'] . "' GROUP BY e.CV_CCT";
$result = $conn->query($sql); $result = $conn->query($sql);
if ($result->num_rows > 0) { if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$nombre_escuela = $row['NOMBRECT'];
$clave_escuela = $row['CV_CCT'];
$_SESSION['clave_escuela']= $row['CV_CCT'];
}
} else { } else {
$sql = 'SELECT * FROM Preescolar WHERE CV_CCT ="' . $_SESSION['clave_escuela'] . '"';
$result = $conn->query($sql);
if ($result->num_rows > 0) {
} else {
$sql = 'SELECT * FROM Primaria WHERE CV_CCT ="' . $_SESSION['clave_escuela'] . '"';
$result = $conn->query($sql);
if ($result->num_rows > 0) {
} else {
$sql = 'SELECT * FROM Secundaria WHERE CV_CCT ="' . $_SESSION['clave_escuela'] . '"';
$result = $conn->query($sql);
if ($result->num_rows > 0) {
} else {
$sql = 'SELECT * FROM Media WHERE CV_CCT ="' . $_SESSION['clave_escuela'] . '"';
$result = $conn->query($sql);
if ($result->num_rows > 0) {
} else {
$sql = 'SELECT * FROM Superior WHERE CV_CCT ="' . $_SESSION['clave_escuela'] . '"';
$result = $conn->query($sql);
if ($result->num_rows > 0) {
} else {
header("location: index.php?err=1"); header("location: index.php?err=1");
mysql_close(); mysql_close();
}
}
}
}
}
} }
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
...@@ -113,12 +85,12 @@ if ($result->num_rows > 0) { ...@@ -113,12 +85,12 @@ if ($result->num_rows > 0) {
<form action="encuesta.php" method="post"> <form action="encuesta.php" method="post">
<input type="hidden" name="escuela" value="<?= $_SESSION["escuela"] ?>"> <input type="hidden" name="escuela" value="<?= $nombre_escuela ?>">
<input type="hidden" name="clave_escuela" value="<?= $clave_escuela; ?>">
<div class="mt-4 text-center" style="margin-top: -20px!important; color: white;"> <div class="mt-4 text-center" style="margin-top: -20px!important; color: white;">
<b> <b>
<h1>Escuela:</h1> <h1>Escuela:</h1>
<h2 style="font-size: 25px;"><?= $_SESSION["escuela"] ?></h2> <h2 style="font-size: 25px;"><?= $nombre_escuela ?></h2>
<div class="d-flex justify-content-center links" style="margin-top: 100px!important;"> <div class="d-flex justify-content-center links" style="margin-top: 100px!important;">
<b>¿EN QUÉ LENGUAJE DESEA CONTESTAR? <b>¿EN QUÉ LENGUAJE DESEA CONTESTAR?
<br> <br>
...@@ -129,7 +101,9 @@ if ($result->num_rows > 0) { ...@@ -129,7 +101,9 @@ if ($result->num_rows > 0) {
<div class="d-flex justify-content-center mt-3 login_container"> <div class="d-flex justify-content-center mt-3 login_container">
<div class="col-md-6"> <div class="col-md-6">
<button id="bespa" type="submit" name="idioma" value="Español" class="btn login_btn">Español</button> <button id="bespa" type="submit" name="idioma" value="Español" class="btn login_btn">
Español
</button>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<button type="submit" name="idioma" value="Maya" class="btn login_btn">Maya</button> <button type="submit" name="idioma" value="Maya" class="btn login_btn">Maya</button>
......
<!-- <!--
/* Coded by Ing. Ulises Morales Ramirez */ /* Coded by Ing. Ulises Morales Ramirez */
--> -->
<?php session_start(); ?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
...@@ -99,8 +99,9 @@ ...@@ -99,8 +99,9 @@
</div> </div>
<script> <script>
function redireccion() { function redireccion() {
var clave_escuela= "<?php echo $_GET['clave_escuela'];?>";
setTimeout(function () { setTimeout(function () {
window.location.replace("lenguaje.php"); window.location.replace("lenguaje.php?clave_escuela="+clave_escuela);
}, 2000); }, 2000);
} }
</script> </script>
......
...@@ -13,6 +13,7 @@ $(document).ready(function () { ...@@ -13,6 +13,7 @@ $(document).ready(function () {
$("#search-box").css("background", "#FFF"); $("#search-box").css("background", "#FFF");
} }
}); });
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment