/
index.php
90 lines (85 loc) · 3.44 KB
/
index.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
include('includes/config.php');
include_once($path_classes.'fla_usuarios.class.php');
$objUsuarios = new fla_usuarios();
$arrUsuario = array();
$msg = "";
$msgRetorno = "";
if (!empty($_POST)) {
$login = $_POST['login'];
$senha = $_POST['senha'];
$objUsuarios->set_des_login($login);
$objUsuarios->set_des_senha($senha);
// Pesquisando os dados do usuário na base e armazenando no array
$arrUsuario = $objUsuarios->logaUsuario($objUsuarios);
// Verifica se retornou algum valor no array
if (count($arrUsuario) > 0) {
// Verifica se o usuário está ativo
if ($arrUsuario[0]['ind_ativo'] == 1) {
// Armazena o nome e o tipo de usuário em sessão
session_start();
$_SESSION['NOM_USUARIO'] = $arrUsuario[0]['nom_usuario'];
$_SESSION['COD_TIPO_USUARIO'] = $arrUsuario[0]['cod_tipo'];
$rotatividade = $url . "rotatividade/index.php";
header("Location:$rotatividade");
} else {
// Se o usuário não estiver ativo, exibe uma mensagem ao usuário
$msg = 'Desculpe, sua conta não está ativa no sistema';
}
} else {
// Se o array voltou vazio, os dados preenchidos estão incorretos, então exibe uma mensagem ao usuário
$msg = "Desculpe, login ou senha incorretos";
}
}
?>
<html>
<head>
<title><?php echo $titulo_pagina; ?> </title>
<link href="./images/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="content">
<div class="data">
<h1 style="text-align:center;font-weight:bolder;">
<?php echo $titulo_pagina; ?>
</h1>
<form name="login" action="index.php" method="POST">
<table id="pagina_login">
<tr>
<th colspan="2">Login de acesso</th>
</tr>
<tr>
<td colspan="2" class="error">
<?php echo $msg; ?>
</td>
</tr>
<tr>
<td>
<label for="login">Usuário:</label>
</td>
<td>
<input type="text" id="login" name="login" maxlength="20" size="20"> <br>
</td>
</tr>
<tr>
<td>
<label for="senha">Senha: </label>
</td>
<td>
<input type="password" id="senha" name="senha" maxlength="20" size="20">
</td>
</tr>
<tr>
<td colspan="2" style="text-align:center;">
<input type="submit" name="acessar" value="Entrar">
</td>
</tr>
</table>
</form>
</div>
<?php
include_once($path_relative . 'rodape.php');
?>
</div>
</body>
</html>