Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.04 KB | None | 0 0
  1. <?php
  2. if (isset($_POST["search"]) && $_POST["search"]!="" && strlen($_POST["search"])>=3) {
  3. $search = strip_tags($_POST["search"]);
  4. require "../../Connections/connections.php";
  5. $new = '%' . $search . '%';
  6. session_start();
  7. $pesquisa = mb_strtolower($search);
  8.  
  9. /* contactos */
  10. $link = new_db_connection();
  11. $stmt = mysqli_stmt_init($link);
  12. $query = "SELECT escolas.nome FROM escolas WHERE escolas.nome LIKE ? OR escolas.sigla LIKE ?";
  13. if (mysqli_stmt_prepare($stmt, $query)) {
  14. mysqli_stmt_bind_param($stmt, 'ss', $new, $new);
  15. /* execute the prepared statement */
  16. if (!mysqli_stmt_execute($stmt)) {
  17. echo "erro;" . mysqli_stmt_error($stmt);
  18. }
  19. mysqli_stmt_bind_result($stmt, $escola);
  20. while (mysqli_stmt_fetch($stmt)) {
  21. $_SESSION["asuapesquisa"] = $_POST["search"];
  22. header("Location: ../Paginas/contactos.php#resultado");
  23. }
  24. mysqli_stmt_close($stmt);
  25. } else {
  26. echo "Error: " . mysqli_error($link);
  27. }
  28. mysqli_close($link);
  29.  
  30. /* atividades */
  31. $link2 = new_db_connection();
  32. $stmt2 = mysqli_stmt_init($link2);
  33. $query2 = "SELECT titulo FROM atividades WHERE titulo LIKE ?";
  34. if (mysqli_stmt_prepare($stmt2, $query2)) {
  35. mysqli_stmt_bind_param($stmt2, 's', $new);
  36. /* execute the prepared statement */
  37. if (!mysqli_stmt_execute($stmt2)) {
  38. echo "erro;" . mysqli_stmt_error($stmt2);
  39. }
  40. mysqli_stmt_bind_result($stmt2, $titulo);
  41. while (mysqli_stmt_fetch($stmt2)) {
  42. $_SESSION["asuapesquisa"] = $_POST["search"];
  43. header("Location: ../Paginas/atividades.php#resultado");
  44. }
  45. mysqli_stmt_close($stmt2);
  46. } else {
  47. echo "Error: " . mysqli_error($link2);
  48. }
  49. mysqli_close($link2);
  50.  
  51. /* serviços */
  52. $link3 = new_db_connection();
  53. $stmt3 = mysqli_stmt_init($link3);
  54. $query3 = "SELECT nome FROM servicos WHERE nome LIKE ?";
  55. if (mysqli_stmt_prepare($stmt3, $query3)) {
  56. mysqli_stmt_bind_param($stmt3, 's', $new);
  57. /* execute the prepared statement */
  58. if (!mysqli_stmt_execute($stmt3)) {
  59. echo "erro;" . mysqli_stmt_error($stmt3);
  60. }
  61. mysqli_stmt_bind_result($stmt3, $servico);
  62. while (mysqli_stmt_fetch($stmt3)) {
  63. $_SESSION["asuapesquisa"] = $_POST["search"];
  64. header("Location: ../Paginas/servicos.php#resultado");
  65. }
  66. mysqli_stmt_close($stmt3);
  67. } else {
  68. echo "Error: " . mysqli_error($link3);
  69. }
  70. mysqli_close($link3);
  71.  
  72. /* oferta */
  73. $link4 = new_db_connection();
  74. $stmt4 = mysqli_stmt_init($link4);
  75. $query4 = "SELECT nivel_ensino FROM ofertaformativa WHERE nivel_ensino LIKE ?";
  76. if (mysqli_stmt_prepare($stmt4, $query4)) {
  77. mysqli_stmt_bind_param($stmt4, 's', $new);
  78. /* execute the prepared statement */
  79. if (!mysqli_stmt_execute($stmt4)) {
  80. echo "erro;" . mysqli_stmt_error($stmt4);
  81. }
  82. mysqli_stmt_bind_result($stmt4, $nivel);
  83. while (mysqli_stmt_fetch($stmt4)) {
  84. $_SESSION["asuapesquisa"] = $_POST["search"];
  85. header("Location: ../Paginas/oferta_formativa.php#resultado");
  86. }
  87. mysqli_stmt_close($stmt4);
  88. } else {
  89. echo "Error: " . mysqli_error($link4);
  90. }
  91. mysqli_close($link4);
  92.  
  93. /* eventos */
  94. $link5 = new_db_connection();
  95. $stmt5 = mysqli_stmt_init($link5);
  96. $query5 = "SELECT eventos FROM eventos WHERE eventos LIKE ?";
  97. if (mysqli_stmt_prepare($stmt5, $query5)) {
  98. mysqli_stmt_bind_param($stmt5, 's', $new);
  99. /* execute the prepared statement */
  100. if (!mysqli_stmt_execute($stmt5)) {
  101. echo "erro;" . mysqli_stmt_error($stmt5);
  102. }
  103. mysqli_stmt_bind_result($stmt5, $evento);
  104. while (mysqli_stmt_fetch($stmt5)) {
  105. $_SESSION["asuapesquisa"] = $_POST["search"];
  106. header("Location: ../calendario.php#resultado");
  107. }
  108. mysqli_stmt_close($stmt5);
  109. } else {
  110. echo "Error: " . mysqli_error($link5);
  111. }
  112. mysqli_close($link5);
  113.  
  114. /* documentos */
  115. $link6 = new_db_connection();
  116. $stmt6 = mysqli_stmt_init($link6);
  117. $query6 = "SELECT titulo FROM documentos WHERE titulo LIKE ?";
  118. if (mysqli_stmt_prepare($stmt6, $query6)) {
  119. mysqli_stmt_bind_param($stmt6, 's', $new);
  120. /* execute the prepared statement */
  121. if (!mysqli_stmt_execute($stmt6)) {
  122. echo "erro;" . mysqli_stmt_error($stmt6);
  123. }
  124. mysqli_stmt_bind_result($stmt6, $doc);
  125. while (mysqli_stmt_fetch($stmt6)) {
  126. $_SESSION["asuapesquisa"] = $_POST["search"];
  127. header("Location: ../Paginas/documentos.php#resultado");
  128. }
  129. mysqli_stmt_close($stmt6);
  130. } else {
  131. echo "Error: " . mysqli_error($link6);
  132. }
  133. mysqli_close($link6);
  134.  
  135. /* noticias */
  136. $link7 = new_db_connection();
  137. $stmt7 = mysqli_stmt_init($link7);
  138. $query7 = "SELECT titulo FROM noticias WHERE titulo LIKE ?";
  139. if (mysqli_stmt_prepare($stmt7, $query7)) {
  140. mysqli_stmt_bind_param($stmt7, 's', $new);
  141. /* execute the prepared statement */
  142. if (!mysqli_stmt_execute($stmt7)) {
  143. echo "erro;" . mysqli_stmt_error($stmt7);
  144. }
  145. mysqli_stmt_bind_result($stmt7, $not);
  146. while (mysqli_stmt_fetch($stmt7)) {
  147. $_SESSION["asuapesquisa"] = $_POST["search"];
  148. header("Location: ../Paginas/index.php#resultado");
  149. }
  150. mysqli_stmt_close($stmt7);
  151. } else {
  152. echo "Error: " . mysqli_error($link7);
  153. }
  154. mysqli_close($link7);
  155.  
  156.  
  157.  
  158. switch ($pesquisa) {
  159. case 'História':
  160. case 'Historia':
  161. case 'história':
  162. case 'historia':
  163. case 'hist':
  164. $_SESSION["asuapesquisa"] = $_POST["search"];
  165. $redireciona = 'história.php';
  166. header("Location: ../Paginas/$redireciona#resultado");
  167. break;
  168. case 'Documentos':
  169. case 'documentos':
  170. case 'Doc':
  171. case 'doc':
  172. case 'Docs':
  173. case 'docs':
  174. $_SESSION["asuapesquisa"] = $_POST["search"];
  175. $redireciona = 'documentos.php';
  176. header("Location: ../Paginas/$redireciona#resultado");
  177. break;
  178. case 'Ementas':
  179. case 'ementas':
  180. case 'comer':
  181. case 'Comer':
  182. case 'senhas':
  183. case 'Senhas':
  184. case 'senha':
  185. case 'Senha':
  186. case 'refeições':
  187. case 'Refeições':
  188. case 'refeicoes':
  189. case 'Refeicoes':
  190. case 'refeicao':
  191. case 'Refeicao':
  192. case 'Refeição':
  193. case 'refeição':
  194. $_SESSION["asuapesquisa"] = $_POST["search"];
  195. $redireciona = 'ementas.php';
  196. header("Location: ../Paginas/$redireciona#resultado");
  197. break;
  198. case 'atividades':
  199. case 'Atividades':
  200. case 'Clubes':
  201. case 'clube':
  202. $_SESSION["asuapesquisa"] = $_POST["search"];
  203. $redireciona = 'atividades.php';
  204. header("Location: ../Paginas/$redireciona#resultado");
  205. break;
  206. case 'oferta':
  207. case 'Oferta':
  208. case 'Cursos':
  209. case 'cursos':
  210. $_SESSION["asuapesquisa"] = $_POST["search"];
  211. $redireciona = 'oferta_formativa.php';
  212. header("Location: ../Paginas/$redireciona#resultado");
  213. break;
  214. case 'serviços':
  215. case 'servicos':
  216. case 'Serviços':
  217. case 'Servicos':
  218. $_SESSION["asuapesquisa"] = $_POST["search"];
  219. $redireciona = 'servicos.php';
  220. header("Location: ../Paginas/$redireciona#resultado");
  221. break;
  222. case 'Contactos':
  223. case 'contactos':
  224. case 'Contacto':
  225. case 'contacto':
  226. case 'Telefone':
  227. case 'telefone':
  228. case 'Telemóveis':
  229. case 'telemóveis':
  230. case 'Telemóvel':
  231. case 'telemóvel':
  232. case 'Telemovel':
  233. case 'telemovel':
  234. case 'Escolas':
  235. case 'escolas':
  236. $_SESSION["asuapesquisa"] = $_POST["search"];
  237. $redireciona = 'contactos.php';
  238. header("Location: ../Paginas/$redireciona#resultado");
  239. break;
  240. case 'calendário':
  241. case 'Calendário':
  242. case 'calendario':
  243. case 'Calendario':
  244. case 'Eventos':
  245. case 'eventos':
  246. case 'Evento':
  247. case 'evento':
  248. $_SESSION["asuapesquisa"] = $_POST["search"];
  249. $redireciona = 'calendario.php';
  250. header("Location: ../$redireciona#resultado");
  251. break;
  252. }
  253. $_SESSION["mal"] = $_POST["search"];
  254. echo "<script>javascript:history.back(-1)</script>";
  255. } else {
  256. $_SESSION["mal"] = $_POST["search"];
  257. echo "<script>javascript:history.back(-1)</script>";
  258. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement