-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
30 lines (26 loc) · 852 Bytes
/
login.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
<?php
session_start();
if (empty($_POST['user']) || empty($_POST['senha'])){
header('location: logar.php?erro=Os campos não podem ficar vazios.');
}
else{
$usuario = $_POST['user'];
$senha = $_POST['senha'];
include 'database/connection.php';
$SQL = 'SELECT * FROM usuario WHERE nickUsuario = :nick and senhaUsuario = :senha';
$RESULT = $conn->prepare($SQL);
$RESULT->bindParam(':nick', $usuario);
$RESULT->bindParam(':senha', $senha);
$RESULT->execute();
$ROWS = $RESULT->fetch(PDO::FETCH_OBJ);
if (($usuario == $ROWS->nickUsuario) && ($senha == $ROWS->senhaUsuario)){
$_SESSION['logado'] = true;
$_SESSION['nome'] = $ROWS->nomeUsuario;
$_SESSION['iduser'] = $ROWS->idUsuario;
header('location: sistema/painel.php');
}
else{
header('location: logar.php?erro=Usuário ou senha inválidos!');
}
}
?>