Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_POST["search"]) && $_POST["search"]!="" && strlen($_POST["search"])>=3) {
- $search = strip_tags($_POST["search"]);
- require "../../Connections/connections.php";
- $new = '%' . $search . '%';
- session_start();
- $pesquisa = mb_strtolower($search);
- /* contactos */
- $link = new_db_connection();
- $stmt = mysqli_stmt_init($link);
- $query = "SELECT escolas.nome FROM escolas WHERE escolas.nome LIKE ? OR escolas.sigla LIKE ?";
- if (mysqli_stmt_prepare($stmt, $query)) {
- mysqli_stmt_bind_param($stmt, 'ss', $new, $new);
- /* execute the prepared statement */
- if (!mysqli_stmt_execute($stmt)) {
- echo "erro;" . mysqli_stmt_error($stmt);
- }
- mysqli_stmt_bind_result($stmt, $escola);
- while (mysqli_stmt_fetch($stmt)) {
- $_SESSION["asuapesquisa"] = $_POST["search"];
- header("Location: ../Paginas/contactos.php#resultado");
- }
- mysqli_stmt_close($stmt);
- } else {
- echo "Error: " . mysqli_error($link);
- }
- mysqli_close($link);
- /* atividades */
- $link2 = new_db_connection();
- $stmt2 = mysqli_stmt_init($link2);
- $query2 = "SELECT titulo FROM atividades WHERE titulo LIKE ?";
- if (mysqli_stmt_prepare($stmt2, $query2)) {
- mysqli_stmt_bind_param($stmt2, 's', $new);
- /* execute the prepared statement */
- if (!mysqli_stmt_execute($stmt2)) {
- echo "erro;" . mysqli_stmt_error($stmt2);
- }
- mysqli_stmt_bind_result($stmt2, $titulo);
- while (mysqli_stmt_fetch($stmt2)) {
- $_SESSION["asuapesquisa"] = $_POST["search"];
- header("Location: ../Paginas/atividades.php#resultado");
- }
- mysqli_stmt_close($stmt2);
- } else {
- echo "Error: " . mysqli_error($link2);
- }
- mysqli_close($link2);
- /* serviços */
- $link3 = new_db_connection();
- $stmt3 = mysqli_stmt_init($link3);
- $query3 = "SELECT nome FROM servicos WHERE nome LIKE ?";
- if (mysqli_stmt_prepare($stmt3, $query3)) {
- mysqli_stmt_bind_param($stmt3, 's', $new);
- /* execute the prepared statement */
- if (!mysqli_stmt_execute($stmt3)) {
- echo "erro;" . mysqli_stmt_error($stmt3);
- }
- mysqli_stmt_bind_result($stmt3, $servico);
- while (mysqli_stmt_fetch($stmt3)) {
- $_SESSION["asuapesquisa"] = $_POST["search"];
- header("Location: ../Paginas/servicos.php#resultado");
- }
- mysqli_stmt_close($stmt3);
- } else {
- echo "Error: " . mysqli_error($link3);
- }
- mysqli_close($link3);
- /* oferta */
- $link4 = new_db_connection();
- $stmt4 = mysqli_stmt_init($link4);
- $query4 = "SELECT nivel_ensino FROM ofertaformativa WHERE nivel_ensino LIKE ?";
- if (mysqli_stmt_prepare($stmt4, $query4)) {
- mysqli_stmt_bind_param($stmt4, 's', $new);
- /* execute the prepared statement */
- if (!mysqli_stmt_execute($stmt4)) {
- echo "erro;" . mysqli_stmt_error($stmt4);
- }
- mysqli_stmt_bind_result($stmt4, $nivel);
- while (mysqli_stmt_fetch($stmt4)) {
- $_SESSION["asuapesquisa"] = $_POST["search"];
- header("Location: ../Paginas/oferta_formativa.php#resultado");
- }
- mysqli_stmt_close($stmt4);
- } else {
- echo "Error: " . mysqli_error($link4);
- }
- mysqli_close($link4);
- /* eventos */
- $link5 = new_db_connection();
- $stmt5 = mysqli_stmt_init($link5);
- $query5 = "SELECT eventos FROM eventos WHERE eventos LIKE ?";
- if (mysqli_stmt_prepare($stmt5, $query5)) {
- mysqli_stmt_bind_param($stmt5, 's', $new);
- /* execute the prepared statement */
- if (!mysqli_stmt_execute($stmt5)) {
- echo "erro;" . mysqli_stmt_error($stmt5);
- }
- mysqli_stmt_bind_result($stmt5, $evento);
- while (mysqli_stmt_fetch($stmt5)) {
- $_SESSION["asuapesquisa"] = $_POST["search"];
- header("Location: ../calendario.php#resultado");
- }
- mysqli_stmt_close($stmt5);
- } else {
- echo "Error: " . mysqli_error($link5);
- }
- mysqli_close($link5);
- /* documentos */
- $link6 = new_db_connection();
- $stmt6 = mysqli_stmt_init($link6);
- $query6 = "SELECT titulo FROM documentos WHERE titulo LIKE ?";
- if (mysqli_stmt_prepare($stmt6, $query6)) {
- mysqli_stmt_bind_param($stmt6, 's', $new);
- /* execute the prepared statement */
- if (!mysqli_stmt_execute($stmt6)) {
- echo "erro;" . mysqli_stmt_error($stmt6);
- }
- mysqli_stmt_bind_result($stmt6, $doc);
- while (mysqli_stmt_fetch($stmt6)) {
- $_SESSION["asuapesquisa"] = $_POST["search"];
- header("Location: ../Paginas/documentos.php#resultado");
- }
- mysqli_stmt_close($stmt6);
- } else {
- echo "Error: " . mysqli_error($link6);
- }
- mysqli_close($link6);
- /* noticias */
- $link7 = new_db_connection();
- $stmt7 = mysqli_stmt_init($link7);
- $query7 = "SELECT titulo FROM noticias WHERE titulo LIKE ?";
- if (mysqli_stmt_prepare($stmt7, $query7)) {
- mysqli_stmt_bind_param($stmt7, 's', $new);
- /* execute the prepared statement */
- if (!mysqli_stmt_execute($stmt7)) {
- echo "erro;" . mysqli_stmt_error($stmt7);
- }
- mysqli_stmt_bind_result($stmt7, $not);
- while (mysqli_stmt_fetch($stmt7)) {
- $_SESSION["asuapesquisa"] = $_POST["search"];
- header("Location: ../Paginas/index.php#resultado");
- }
- mysqli_stmt_close($stmt7);
- } else {
- echo "Error: " . mysqli_error($link7);
- }
- mysqli_close($link7);
- switch ($pesquisa) {
- case 'História':
- case 'Historia':
- case 'história':
- case 'historia':
- case 'hist':
- $_SESSION["asuapesquisa"] = $_POST["search"];
- $redireciona = 'história.php';
- header("Location: ../Paginas/$redireciona#resultado");
- break;
- case 'Documentos':
- case 'documentos':
- case 'Doc':
- case 'doc':
- case 'Docs':
- case 'docs':
- $_SESSION["asuapesquisa"] = $_POST["search"];
- $redireciona = 'documentos.php';
- header("Location: ../Paginas/$redireciona#resultado");
- break;
- case 'Ementas':
- case 'ementas':
- case 'comer':
- case 'Comer':
- case 'senhas':
- case 'Senhas':
- case 'senha':
- case 'Senha':
- case 'refeições':
- case 'Refeições':
- case 'refeicoes':
- case 'Refeicoes':
- case 'refeicao':
- case 'Refeicao':
- case 'Refeição':
- case 'refeição':
- $_SESSION["asuapesquisa"] = $_POST["search"];
- $redireciona = 'ementas.php';
- header("Location: ../Paginas/$redireciona#resultado");
- break;
- case 'atividades':
- case 'Atividades':
- case 'Clubes':
- case 'clube':
- $_SESSION["asuapesquisa"] = $_POST["search"];
- $redireciona = 'atividades.php';
- header("Location: ../Paginas/$redireciona#resultado");
- break;
- case 'oferta':
- case 'Oferta':
- case 'Cursos':
- case 'cursos':
- $_SESSION["asuapesquisa"] = $_POST["search"];
- $redireciona = 'oferta_formativa.php';
- header("Location: ../Paginas/$redireciona#resultado");
- break;
- case 'serviços':
- case 'servicos':
- case 'Serviços':
- case 'Servicos':
- $_SESSION["asuapesquisa"] = $_POST["search"];
- $redireciona = 'servicos.php';
- header("Location: ../Paginas/$redireciona#resultado");
- break;
- case 'Contactos':
- case 'contactos':
- case 'Contacto':
- case 'contacto':
- case 'Telefone':
- case 'telefone':
- case 'Telemóveis':
- case 'telemóveis':
- case 'Telemóvel':
- case 'telemóvel':
- case 'Telemovel':
- case 'telemovel':
- case 'Escolas':
- case 'escolas':
- $_SESSION["asuapesquisa"] = $_POST["search"];
- $redireciona = 'contactos.php';
- header("Location: ../Paginas/$redireciona#resultado");
- break;
- case 'calendário':
- case 'Calendário':
- case 'calendario':
- case 'Calendario':
- case 'Eventos':
- case 'eventos':
- case 'Evento':
- case 'evento':
- $_SESSION["asuapesquisa"] = $_POST["search"];
- $redireciona = 'calendario.php';
- header("Location: ../$redireciona#resultado");
- break;
- }
- $_SESSION["mal"] = $_POST["search"];
- echo "<script>javascript:history.back(-1)</script>";
- } else {
- $_SESSION["mal"] = $_POST["search"];
- echo "<script>javascript:history.back(-1)</script>";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement