-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
76 lines (70 loc) · 2.45 KB
/
Copy pathindex.php
File metadata and controls
76 lines (70 loc) · 2.45 KB
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
require_once 'config/db.php';
require_once 'message.php';
session_start();
if(isset($_SESSION['id'])) {
header("Location: invoices.php");
exit();
}
if (isset($_POST['email']) && isset($_POST['password'])) {
$email = $_POST['email'];
$password = $_POST['password'];
$alert = '' ;
$query = "SELECT user.id, user.name, rol.name AS rol
FROM user
LEFT JOIN rol ON rol.id = user.rol_id
WHERE user.email = '$email' AND user.password = '$password'
LIMIT 1;
";
$result = $db->query($query);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$_SESSION['id'] = $row['id'];
$_SESSION['name'] = $row['name'];
$_SESSION['rol'] = $row['rol'];
header("Location: invoices.php");
}
} else{
$alert = message('Correo o contraseña son incorrectos', 'error');
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/styles.css?v=<?php echo time(); ?>">
<title>Document</title>
</head>
<body class="login-container">
<div class="login">
<div class="login-icon">
<i data-lucide="key-round"></i>
</div>
<h1 class="login-title">Iniciar Sesión</h1>
<p class="login-subtitle ">Llene el formulario para acceder al sistema</p>
<?php if(isset($alert)): ?>
<?php echo $alert; ?>
<?php endif; ?>
<form class="form-login" method="post" action="index.php">
<div class="form-login-body">
<div class="form-login-item">
<label class="label" for="email">Correo Electrónico</label>
<input class="input" type="email" id="email" name="email" placeholder="exemple@gmail.com">
</div>
<div class="form-login-item">
<label class="label" for="password">Contraseña</label>
<input class="input" type="password" id="password" name="password" placeholder="••••••••••••">
</div>
</div>
<button class="form-login-submit btn btn--primary" type="submit">Iniciar Sesión</button>
</form>
</div>
</body>
</html>
<script src="https://unpkg.com/lucide@latest"></script>
<script>
lucide.createIcons();
</script>