-
Notifications
You must be signed in to change notification settings - Fork 0
/
validar.php
45 lines (31 loc) · 1.09 KB
/
validar.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
<?php
session_start();
include 'banco.php';
$funcao = $_POST['tipo'];
$usuario = $_POST['login'];
$senha = $_POST['senha'];
if ($funcao == 'Cliente'){
$sql = "select * from cliente where user = '$usuario' and senha = '$senha' ";
$consulta = $conexao->query($sql);
if ($consulta->num_rows > 0) {
$_SESSION['login'] = $usuario;
$_SESSION['senha'] = $senha;
header('location:_cliente/index.php');
} else {
unset ($_SESSION['login']);
unset ($_SESSION['senha']);
header('location: index.php?login=erro');
}
}else{ $sql = "select * from usuario where user = '$usuario' and senha = '$senha' ";
$consulta = $conexao->query($sql);
if ($consulta->num_rows > 0) {
$_SESSION['login'] = $usuario;
$_SESSION['senha'] = $senha;
header('location:_server/index.php');
} else {
unset ($_SESSION['login']);
unset ($_SESSION['senha']);
header('location: index.php?login=erro');
}
}
?>