-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
108 lines (80 loc) · 2.79 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
require 'connection/conexao.php';
?><html>
<head>
<head>
<meta charset="utf-8">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.js" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<title>
Login
</title>
</head>
<body>
<div class="container ">
<div class="row">
<div class="col s6 offset-s3">
<div class="section">
<legend class="col s6 offset-s3 ">
<div class="">
<h4>Seja Bem Vindo!</h4>
</div>
</div>
</legend>
<div class="section">
<form action="#" method="post">
<div class="section">
<div class="section">
<div class="section">
<div class="section">
<div class="section">
<div class="section">
<div class="section">
<label for="login">
CPF
</label>
<div>
<input class="form-control" type="text" id="login" name="login">
</div>
<label for="senha">
Senha
</label>
<input class="form-control" type="password" id="senha" name="senha">
<div class="section">
<div class="col s6 offset-s5 ">
<input class="btn btn-primary " type="submit" id="enviar" name="enviar" value="Enviar">
</div>
</form>
</div>
</div>
</div>
</body>
</html>
<?php
if (isset($_POST["enviar"])) {
$login = $_POST["login"];
$senha = $_POST["senha"];
if (empty($login) || empty($senha)) {
echo "Digite um login e uma senha!";
exit;
}
$senha = md5($senha);
print($senha);
$result = mysqli_query($conn, "SELECT * FROM funcionario WHERE cpf_func = '" . $login . "' and senha_func = '" . $senha . "';");
if ($registro = mysqli_fetch_array($result)) {
session_start();
$_SESSION["usuario"]["logado"] = true;
$_SESSION["usuario"]["login"] = $registro["login"];
$_SESSION["usuario"]["nome"] = $registro["nome"];
$_SESSION["usuario"]["gerente"] = $registro["gerente"] == "t" ? true : false;
header("location: menu.php");
} else {
echo "Login e/ou senha incorreto(s)!";
}
mysqli_close($conn);
}