-
Notifications
You must be signed in to change notification settings - Fork 0
/
autenticacaoUsuario.php
55 lines (49 loc) · 1.3 KB
/
autenticacaoUsuario.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
<?php
$host = "localhost";
$user = "root";
$pass = "";
$banco = "user";
$conexao = mysql_connect($host, $user, $pass);
mysql_select_db($banco) or die (mysql_error());
?>
<html>
<head>
<title>Autenticando Usuario</title>
<script type="text/javascript">
function loginsuccessfully(){
setTimeout("window.location='paginicial.php'",1000);
}
function loginsuccessfully2(){
setTimeout("window.location='Painel.php'",1000);
}
function loginfailed(){
setTimeout("window.location='login.php'",1000);
}
</script>
</head>
<body>
<?php
$usuario = $_POST['usuario'];
$senha = $_POST['senha'];
$sql = mysql_query("SELECT * FROM usuario WHERE user = '$usuario' and password = '$senha'") or die(mysql_error());
$row = mysql_num_rows($sql);
$tuser= mysql_fetch_array($sql);
$tusuario = $tuser['tuser'];
if($row > 0 ){
session_start();
$_SESSION['user']=$_POST['usuario'];
$_SESSION['password']=$_POST['senha'];
$_SESSION['tuser']=$tusuario;
echo "<center>Você foi autenticado com sucesso! Aguarde um instante...</center>";
if ($tusuario>1) {
echo "<script>loginsuccessfully()</script>";
} else {
echo "<script>loginsuccessfully2()</script>";
}
}else {
echo "<center>Nome de usuario ou senha invalida! Retornando para tela de login...</center>";
echo "<script>loginfailed()</script>";
}
?>
</body>
</html>