-
Notifications
You must be signed in to change notification settings - Fork 0
/
carregaInstituicao.php
67 lines (46 loc) · 1.32 KB
/
carregaInstituicao.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
include_once "conexao.php";
include_once "Usuario.php";
if(!isset($_SESSION)) session_start();
$conexao = conexao::getConexao();
if(!isset($_SESSION["usuario"])){
header("location: index.php");
}
$dados = $_SESSION["usuario"];
$nivelAcesso = $dados->getNivelAcesso();
if($nivelAcesso != "A"){
header("location: index.php");
}
//Código acima - verificação de login
if(isset($_POST["min"]) && isset($_POST["txt"])){
$conexao = conexao::getConexao();
$min = trim(addslashes($_POST["min"]));
$texto = htmlspecialchars(trim(addslashes($_POST["txt"])));
$comando = $conexao->prepare("SELECT * FROM instituicao");
$comando->execute();
$dados = $comando->fetchAll();
if(count($dados) > 0){
$comando = $conexao->prepare("SELECT * FROM instituicao WHERE nome_instituicao LIKE :txt LIMIT $min, 10");
$comando->bindValue(":txt", "%$texto%");
$comando->execute();
$dados = $comando->fetchAll();
$html = null;
if(count($dados) > 0){
foreach($dados as $value) {
$codigo = htmlspecialchars($value[0]);
$nome = htmlspecialchars($value[1]);
$html .= "<tr ondblclick='selecionaInstituicao($codigo, `$nome`)'>
<td>$nome</td>
</tr>";
}
}else{
$html = "";
}
echo $html;
}else{
echo "";
}
}else{
header("location: cadAluno.php");
}
?>