-
Notifications
You must be signed in to change notification settings - Fork 0
/
ope.php
56 lines (37 loc) · 996 Bytes
/
ope.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
<?php
session_start();
require("PassHash.php");
include("connection.php");
//variaveis locais
$login = $_POST['login'];
$senha = $_POST['senha'];
//*********************
$sql = "SELECT senha,nivel FROM cadastros WHERE name = ?";
$stmt = $con->prepare($sql);
$stmt->bind_param("s",$login);
$stmt->execute() or die("Erro 00");
//verificicando se houve resultset
//iterando para descobrir se o usuario eh medico ou paciente
$stmt->bind_result($passwd,$nivel1) or die("Erro 01");
while ($stmt->fetch()) {
$nivel = $nivel1;
$password = $passwd;
}
// verifique se a senha usada bate com o hash guardado
if (PassHash::check_password($password,$senha)) {
if (!isset($_SESSION)) session_start();
$_SESSION['login'] = $login;
$_SESSION['senha'] = $senha;
$_SESSION['nivel'] = $nivel;
if($nivel <= 3) {
header("location: indexCadastro.php"); exit;
}
else {
header("location: adm.php"); exit;
}
}
else {
session_destroy();
header('location:logincadastro.php'); exit;
}
?>