Add log in functionality
This commit is contained in:
parent
1b80190b11
commit
b796f6bf47
|
@ -107,5 +107,5 @@ CREATE TABLE IF NOT EXISTS informe(
|
|||
INSERT INTO rol (codigo, nombre) VALUES (1, "administrativo");
|
||||
INSERT INTO rol (codigo, nombre) VALUES (2, "medico");
|
||||
|
||||
INSERT INTO usuario (nombre, usuario, contraseña, correo, rol) VALUES ("Sysadmin", "Admin", "chimba", "admin@example.com", 1);
|
||||
INSERT INTO usuario (nombre, usuario, contraseña, correo, rol) VALUES ("Sysadmin", "admin", "chimba", "admin@example.com", 1);
|
||||
INSERT INTO usuario (nombre, usuario, contraseña, correo, rol) VALUES ("Nabil", "nabil", "menisco","doctor@example.com", 2);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<!doctype html>
|
||||
<?php session_start(); ?>
|
||||
<html class="no-js" lang="es">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
@ -18,11 +18,15 @@
|
|||
<nav>
|
||||
<ul class="navbar-left">
|
||||
<li class="list"><a href="index.php">Página principal</a></li>
|
||||
<?php if(isset($_SESSION["user"])) : ?>
|
||||
<li class="list"><a href="user.php">Usuarios</a></li>
|
||||
<li class="list"><a href="patient.php">Pacientes</a></li>
|
||||
<li class="list"><a href="appointment.php">Citas</a></li>
|
||||
<li class="list"><a href="holiday.php">Vacaciones</a></li>
|
||||
<?php endif ?>
|
||||
<?php if($_SESSION["user_type"] == 2) : ?>
|
||||
<li class="list"><a href="report.php">Informes</a></li>
|
||||
<?php endif ?>
|
||||
<li class="list"><a href="login.php">Login</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
|
|
@ -7,3 +7,21 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||
|
||||
calendar.render();
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#calendar').fullCalendar({
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,basicWeek,basicDay'
|
||||
},
|
||||
defaultDate: new Date(),
|
||||
navLinks: true, // can click day/week names to navigate views
|
||||
editable: true,
|
||||
eventLimit: true, // allow "more" link when too many events
|
||||
dayClick: function(date, jsEvent, view) {
|
||||
$("#successModal").modal("show");
|
||||
$("#eventDate").val(date.format());
|
||||
},
|
||||
events: <?php echo json_encode($appointments); ?>
|
||||
});
|
||||
|
|
|
@ -243,4 +243,12 @@ function fetchReportData($pdo, string $id) {
|
|||
return $data;
|
||||
}
|
||||
|
||||
function fetchLoginData($pdo, $data){
|
||||
$query = "SELECT usuario, contraseña, rol FROM usuario WHERE usuario=? AND fecha_baja IS NULL";
|
||||
$result = $pdo->prepare($query);
|
||||
$result->execute([$data["usuario"]]);
|
||||
$data = $result->fetch();
|
||||
return $data;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<!doctype html>
|
||||
<?php session_start(); ?>
|
||||
<html class="no-js" lang="es">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
@ -18,10 +18,15 @@
|
|||
<nav>
|
||||
<ul class="navbar-left">
|
||||
<li class="list"><a href="index.php">Página principal</a></li>
|
||||
<?php if(isset($_SESSION["user"])) : ?>
|
||||
<li class="list"><a href="user.php">Usuarios</a></li>
|
||||
<li class="list"><a href="patient.php">Pacientes</a></li>
|
||||
<li class="list"><a href="appointment.php">Citas</a></li>
|
||||
<li class="list"><a href="holiday.php">Vacaciones</a></li>
|
||||
<?php endif ?>
|
||||
<?php if($_SESSION["user_type"] == 2) : ?>
|
||||
<li class="list"><a href="report.php">Informes</a></li>
|
||||
<?php endif ?>
|
||||
<li class="list"><a href="login.php">Login</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<?php session_start(); ?>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
|
@ -12,11 +13,15 @@
|
|||
<nav>
|
||||
<ul class="navbar-left">
|
||||
<li class="list"><a href="index.php">Página principal</a></li>
|
||||
<?php if(isset($_SESSION["user"])) : ?>
|
||||
<li class="list"><a href="user.php">Usuarios</a></li>
|
||||
<li class="list"><a href="patient.php">Pacientes</a></li>
|
||||
<li class="list"><a href="appointment.php">Citas</a></li>
|
||||
<li class="list"><a href="holiday.php">Vacaciones</a></li>
|
||||
<?php endif ?>
|
||||
<?php if($_SESSION["user_type"] == 2) : ?>
|
||||
<li class="list"><a href="report.php">Informes</a></li>
|
||||
<?php endif ?>
|
||||
<li class="list"><a href="login.php">Login</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<?php session_start(); ?>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
|
@ -11,11 +12,15 @@
|
|||
<nav>
|
||||
<ul class="navbar-left">
|
||||
<li class="list"><a href="index.php">Página principal</a></li>
|
||||
<?php if(isset($_SESSION["user"])) : ?>
|
||||
<li class="list"><a href="user.php">Usuarios</a></li>
|
||||
<li class="list"><a href="patient.php">Pacientes</a></li>
|
||||
<li class="list"><a href="appointment.php">Citas</a></li>
|
||||
<li class="list"><a href="holiday.php">Vacaciones</a></li>
|
||||
<?php endif ?>
|
||||
<?php if($_SESSION["user_type"] == 2) : ?>
|
||||
<li class="list"><a href="report.php">Informes</a></li>
|
||||
<?php endif ?>
|
||||
<li class="list"><a href="login.php">Login</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<?php session_start(); ?>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
|
@ -14,11 +15,15 @@
|
|||
<nav>
|
||||
<ul class="navbar-left">
|
||||
<li class="list"><a href="index.php">Página principal</a></li>
|
||||
<?php if(isset($_SESSION["user"])) : ?>
|
||||
<li class="list"><a href="user.php">Usuarios</a></li>
|
||||
<li class="list"><a href="patient.php">Pacientes</a></li>
|
||||
<li class="list"><a href="appointment.php">Citas</a></li>
|
||||
<li class="list"><a href="holiday.php">Vacaciones</a></li>
|
||||
<?php endif ?>
|
||||
<?php if($_SESSION["user_type"] == 2) : ?>
|
||||
<li class="list"><a href="report.php">Informes</a></li>
|
||||
<?php endif ?>
|
||||
<li class="list"><a href="login.php">Login</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<?php session_start(); ?>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
|
@ -11,10 +12,15 @@
|
|||
<nav>
|
||||
<ul class="navbar-left">
|
||||
<li class="list"><a href="index.php">Página principal</a></li>
|
||||
<?php if(isset($_SESSION["user"])) : ?>
|
||||
<li class="list"><a href="user.php">Usuarios</a></li>
|
||||
<li class="list"><a href="patient.php">Pacientes</a></li>
|
||||
<li class="list"><a href="appointment.php">Citas</a></li>
|
||||
<li class="list"><a href="holiday.php">Vacaciones</a></li>
|
||||
<?php endif ?>
|
||||
<?php if($_SESSION["user_type"] == 2) : ?>
|
||||
<li class="list"><a href="report.php">Informes</a></li>
|
||||
<?php endif ?>
|
||||
<li class="list"><a href="login.php">Login</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<?php session_start(); ?>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
|
@ -12,11 +13,15 @@
|
|||
<nav>
|
||||
<ul class="navbar-left">
|
||||
<li class="list"><a href="index.php">Página principal</a></li>
|
||||
<?php if(isset($_SESSION["user"])) : ?>
|
||||
<li class="list"><a href="user.php">Usuarios</a></li>
|
||||
<li class="list"><a href="patient.php">Pacientes</a></li>
|
||||
<li class="list"><a href="appointment.php">Citas</a></li>
|
||||
<li class="list"><a href="holiday.php">Vacaciones</a></li>
|
||||
<?php endif ?>
|
||||
<?php if($_SESSION["user_type"] == 2) : ?>
|
||||
<li class="list"><a href="report.php">Informes</a></li>
|
||||
<?php endif ?>
|
||||
<li class="list"><a href="login.php">Login</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<?php session_start(); ?>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
|
@ -11,11 +12,15 @@
|
|||
<nav>
|
||||
<ul class="navbar-left">
|
||||
<li class="list"><a href="index.php">Página principal</a></li>
|
||||
<?php if(isset($_SESSION["user"])) : ?>
|
||||
<li class="list"><a href="user.php">Usuarios</a></li>
|
||||
<li class="list"><a href="patient.php">Pacientes</a></li>
|
||||
<li class="list"><a href="appointment.php">Citas</a></li>
|
||||
<li class="list"><a href="holiday.php">Vacaciones</a></li>
|
||||
<?php endif ?>
|
||||
<?php if($_SESSION["user_type"] == 2) : ?>
|
||||
<li class="list"><a href="report.php">Informes</a></li>
|
||||
<?php endif ?>
|
||||
<li class="list"><a href="login.php">Login</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<?php session_start(); ?>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
|
@ -12,11 +13,15 @@
|
|||
<nav>
|
||||
<ul class="navbar-left">
|
||||
<li class="list"><a href="index.php">Página principal</a></li>
|
||||
<?php if(isset($_SESSION["user"])) : ?>
|
||||
<li class="list"><a href="user.php">Usuarios</a></li>
|
||||
<li class="list"><a href="patient.php">Pacientes</a></li>
|
||||
<li class="list"><a href="appointment.php">Citas</a></li>
|
||||
<li class="list"><a href="holiday.php">Vacaciones</a></li>
|
||||
<?php endif ?>
|
||||
<?php if($_SESSION["user_type"] == 2) : ?>
|
||||
<li class="list"><a href="report.php">Informes</a></li>
|
||||
<?php endif ?>
|
||||
<li class="list"><a href="login.php">Login</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<?php session_start(); ?>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
|
@ -11,11 +12,15 @@
|
|||
<nav>
|
||||
<ul class="navbar-left">
|
||||
<li class="list"><a href="index.php">Página principal</a></li>
|
||||
<?php if(isset($_SESSION["user"])) : ?>
|
||||
<li class="list"><a href="user.php">Usuarios</a></li>
|
||||
<li class="list"><a href="patient.php">Pacientes</a></li>
|
||||
<li class="list"><a href="appointment.php">Citas</a></li>
|
||||
<li class="list"><a href="holiday.php">Vacaciones</a></li>
|
||||
<?php endif ?>
|
||||
<?php if($_SESSION["user_type"] == 2) : ?>
|
||||
<li class="list"><a href="report.php">Informes</a></li>
|
||||
<?php endif ?>
|
||||
<li class="list"><a href="login.php">Login</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<!doctype html>
|
||||
<?php session_start(); ?>
|
||||
<html class="no-js" lang="es">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
@ -13,11 +13,15 @@
|
|||
<nav>
|
||||
<ul class="navbar-left">
|
||||
<li class="list"><a href="index.php">Página principal</a></li>
|
||||
<?php if(isset($_SESSION["user"])) : ?>
|
||||
<li class="list"><a href="user.php">Usuarios</a></li>
|
||||
<li class="list"><a href="patient.php">Pacientes</a></li>
|
||||
<li class="list"><a href="appointment.php">Citas</a></li>
|
||||
<li class="list"><a href="holiday.php">Vacaciones</a></li>
|
||||
<?php endif ?>
|
||||
<?php if($_SESSION["user_type"] == 2) : ?>
|
||||
<li class="list"><a href="report.php">Informes</a></li>
|
||||
<?php endif ?>
|
||||
<li class="list"><a href="login.php">Login</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<?php session_start(); ?>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
|
@ -11,11 +12,15 @@
|
|||
<nav>
|
||||
<ul class="navbar-left">
|
||||
<li class="list"><a href="index.php">Página principal</a></li>
|
||||
<?php if(isset($_SESSION["user"])) : ?>
|
||||
<li class="list"><a href="user.php">Usuarios</a></li>
|
||||
<li class="list"><a href="patient.php">Pacientes</a></li>
|
||||
<li class="list"><a href="appointment.php">Citas</a></li>
|
||||
<li class="list"><a href="holiday.php">Vacaciones</a></li>
|
||||
<?php endif ?>
|
||||
<?php if($_SESSION["user_type"] == 2) : ?>
|
||||
<li class="list"><a href="report.php">Informes</a></li>
|
||||
<?php endif ?>
|
||||
<li class="list"><a href="login.php">Login</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<?php session_start(); ?>
|
||||
<html class="no-js" lang="es">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
<title>Gestión de usuarios</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="../static/style.css" type="text/css" media="screen" />
|
||||
<script src="validate_user.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav>
|
||||
<ul class="navbar-left">
|
||||
<li class="list"><a href="index.php">Página principal</a></li>
|
||||
<?php if(isset($_SESSION["user"])) : ?>
|
||||
<li class="list"><a href="user.php">Usuarios</a></li>
|
||||
<li class="list"><a href="patient.php">Pacientes</a></li>
|
||||
<li class="list"><a href="appointment.php">Citas</a></li>
|
||||
<li class="list"><a href="holiday.php">Vacaciones</a></li>
|
||||
<?php endif ?>
|
||||
<?php if($_SESSION["user_type"] == 2) : ?>
|
||||
<li class="list"><a href="report.php">Informes</a></li>
|
||||
<?php endif ?>
|
||||
<li class="list"><a href="login.php">Login</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
</body>
|
||||
<form name="login_form" method="post" action="user_management.php" onsubmit="return validateLogin();">
|
||||
<div class="input-group">
|
||||
<label>usuario</label>
|
||||
<input type="text" name="usuario" value="">
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<label>contraseña</label>
|
||||
<input type="password" name="contraseña" value="">
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<button class="btn" type="submit" name="login">Iniciar sesión</button>
|
||||
</div>
|
||||
</form>
|
||||
</html>
|
|
@ -1,4 +1,4 @@
|
|||
<!doctype html>
|
||||
<?php session_start(); ?>
|
||||
<html class="no-js" lang="es">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
@ -13,11 +13,15 @@
|
|||
<nav>
|
||||
<ul class="navbar-left">
|
||||
<li class="list"><a href="index.php">Página principal</a></li>
|
||||
<?php if(isset($_SESSION["user"])) : ?>
|
||||
<li class="list"><a href="user.php">Usuarios</a></li>
|
||||
<li class="list"><a href="patient.php">Pacientes</a></li>
|
||||
<li class="list"><a href="appointment.php">Citas</a></li>
|
||||
<li class="list"><a href="holiday.php">Vacaciones</a></li>
|
||||
<?php endif ?>
|
||||
<?php if($_SESSION["user_type"] == 2) : ?>
|
||||
<li class="list"><a href="report.php">Informes</a></li>
|
||||
<?php endif ?>
|
||||
<li class="list"><a href="login.php">Login</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<!doctype html>
|
||||
<?php session_start(); ?>
|
||||
<html class="no-js" lang="es">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
@ -13,11 +13,15 @@
|
|||
<nav>
|
||||
<ul class="navbar-left">
|
||||
<li class="list"><a href="index.php">Página principal</a></li>
|
||||
<?php if(isset($_SESSION["user"])) : ?>
|
||||
<li class="list"><a href="user.php">Usuarios</a></li>
|
||||
<li class="list"><a href="patient.php">Pacientes</a></li>
|
||||
<li class="list"><a href="appointment.php">Citas</a></li>
|
||||
<li class="list"><a href="holiday.php">Vacaciones</a></li>
|
||||
<?php endif ?>
|
||||
<?php if($_SESSION["user_type"] == 2) : ?>
|
||||
<li class="list"><a href="report.php">Informes</a></li>
|
||||
<?php endif ?>
|
||||
<li class="list"><a href="login.php">Login</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<!doctype html>
|
||||
<?php session_start(); ?>
|
||||
<html class="no-js" lang="es">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
@ -13,11 +13,15 @@
|
|||
<nav>
|
||||
<ul class="navbar-left">
|
||||
<li class="list"><a href="index.php">Página principal</a></li>
|
||||
<?php if(isset($_SESSION["user"])) : ?>
|
||||
<li class="list"><a href="user.php">Usuarios</a></li>
|
||||
<li class="list"><a href="patient.php">Pacientes</a></li>
|
||||
<li class="list"><a href="appointment.php">Citas</a></li>
|
||||
<li class="list"><a href="holiday.php">Vacaciones</a></li>
|
||||
<?php endif ?>
|
||||
<?php if($_SESSION["user_type"] == 2) : ?>
|
||||
<li class="list"><a href="report.php">Informes</a></li>
|
||||
<?php endif ?>
|
||||
<li class="list"><a href="login.php">Login</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
|
|
@ -35,6 +35,21 @@ function userFind(){
|
|||
header("location: user.php?search=$search");
|
||||
}
|
||||
|
||||
function userLogin(){
|
||||
$location = 'login.php';
|
||||
$data = $_POST;
|
||||
$pdo = connectDatabase();
|
||||
$db_data = fetchLoginData($pdo, $data);
|
||||
closeDatabase($pdo);
|
||||
if($data["usuario"] == $db_data["usuario"] && $data["contraseña"] == $db_data["contraseña"]){
|
||||
session_start();
|
||||
$_SESSION["user"] = $db_data["usuario"];
|
||||
$_SESSION["user_type"] = $db_data["rol"];
|
||||
$location = 'index.php';
|
||||
}
|
||||
header("location: $location");
|
||||
}
|
||||
|
||||
if (isset($_POST["create"])) {
|
||||
userCreation();
|
||||
}
|
||||
|
@ -51,3 +66,7 @@ if (isset($_GET["delete"])) {
|
|||
if (isset($_POST["search"])) {
|
||||
userFind();
|
||||
}
|
||||
|
||||
if (isset($_POST["login"])) {
|
||||
userLogin();
|
||||
}
|
||||
|
|
|
@ -45,3 +45,19 @@ function validateUser(){
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
function validateLogin(){
|
||||
var user = document.forms["login_form"]["usuario"];
|
||||
var password = document.forms["login_form"]["contraseña"];
|
||||
|
||||
if(!validateString(user.value)){
|
||||
alert("Introduce el usuario");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!validateString(password.value)){
|
||||
alert("Introduce la contraseña");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -123,21 +123,18 @@ header li a {
|
|||
main {
|
||||
background: white;
|
||||
}
|
||||
|
||||
.hero {
|
||||
/* Sizing */
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
|
||||
/* Flexbox stuff */
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
/* Text styles */
|
||||
text-align: center;
|
||||
color: white;
|
||||
|
||||
/* Background styles */
|
||||
background-image: linear-gradient(rgba(0, 0, 0, 0.5),rgba(0, 0, 0, 0.5)), url('https://www.pepperconstruction.com/sites/default/files/images/pmc1.jpg');
|
||||
background-size: cover;
|
||||
background-position: center center;
|
||||
|
@ -145,3 +142,9 @@ main {
|
|||
background-attachment: fixed;
|
||||
}
|
||||
|
||||
.hero h1 {
|
||||
font-size: 5em;
|
||||
|
||||
margin-top: 0;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue