-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
75 lines (67 loc) · 2.21 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
<?php include 'config/database.php'; ?>
<?php
session_start();
$user = $cont = '';
$error = '';
if (isset($_POST['submit'])) {
// Validamos si ha puesto un usuario
// (Nos lo podriamos saltar pq el HTML tiene puesto el required, pero por si acaso)
if (empty($_POST['user'])) {
$error = "Tienes que poner todos los datos";
} else {
// $user = filter_input(INPUT_POST, 'user', FILTER_SANITIZE_SPECIAL_CHARS);
$user = $_POST['user'];
}
if (empty($_POST['cont'])) {
$error = "Tienes que poner todos los datos";
} else {
$cont = $_POST['cont'];
}
$sql = "SELECT * FROM users WHERE user = '$user' AND cont = '$cont'";
$result = mysqli_query($conec, $sql);
if ($result->num_rows > 0) {
if ($result->fetch_column(4) == 1) {
header('Location: /panel.php');
$_SESSION['user'] = $user;
$_SESSION['perm'] = true;
} else {
$_SESSION['user'] = $user;
$_SESSION['perm'] = false;
header('Location: /inicio.php');
}
} else {
$error = "Contrasñea incorrecta";
}
}
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sistema de voto - FEMAE</title>
<link rel="stylesheet" href="/styles/index.css">
<link rel="manifest" href="manifest.json">
<meta name="theme-color" content="#ffffff" />
</head>
<body>
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register(
'/sw.js'
);
}
</script>
<p class="titulo">Sistema de voto</p>
<img src="/assets/img/pdf-header.png" alt="FEMAE" class="center">
<div class="formulario">
<p>Inicia sesión</p>
<form action="" method="post">
<input type="text" name="user" placeholder="Usuario" required> <br>
<input type="password" name="cont" , placeholder="Contraseña" required><br>
<input type="submit" name="submit" class="submit">
<?= $error ?>
</form>
</div>
<?php include 'inc/footer.php' ?>