-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
76 lines (63 loc) · 1.94 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
<?php
$alert = '';
session_start();
if(!empty($_SESSION['active']))
{
header('location: sistema/');
}else{
if(!empty($_POST))
{
if(empty($_POST['usuario']) || empty($_POST['clave']))
{
$alert = 'Ingrese su usuario y su calve';
}else{
require_once "conexion.php";
$user = mysqli_real_escape_string($conection,$_POST['usuario']);
$pass = md5(mysqli_real_escape_string($conection,$_POST['clave']));
$query = mysqli_query($conection,"SELECT u.idusuario,u.nombre,u.correo,u.usuario,r.idrol,r.rol
FROM usuario u
INNER JOIN rol r
ON u.rol = r.idrol
WHERE u.usuario= '$user' AND u.clave = '$pass' AND u.estatus = 1 ");
mysqli_close($conection);
$result = mysqli_num_rows($query);
if($result > 0)
{
$data = mysqli_fetch_array($query);
$_SESSION['active'] = true;
$_SESSION['idUser'] = $data['idusuario'];
$_SESSION['nombre'] = $data['nombre'];
$_SESSION['email'] = $data['correo'];
$_SESSION['user'] = $data['usuario'];
$_SESSION['rol'] = $data['idrol'];
$_SESSION['rol_name'] = $data['rol'];
header('location: sistema/');
}else{
$alert = 'El usuario o la clave son incorrectos';
session_destroy();
}
}
}
}
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<title>Login | Sistema Facturación</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<section id="container">
<form action="" method="post">
<h3>Iniciar Sesión</h3>
<img src="img/login.png" alt="Login">
<input type="text" name="usuario" placeholder="Usuario">
<input type="password" name="clave" placeholder="Contraseña">
<div class="alert"><?php echo isset($alert) ? $alert : ''; ?></div>
<input type="submit" value="INGRESAR">
</form>
</section>
</body>
</html>