Add log out functionality
This commit is contained in:
parent
6f3d570285
commit
229b03a3c9
|
@ -13,7 +13,7 @@
|
||||||
<script src="calendar.js"></script>
|
<script src="calendar.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php include 'navbar.php' ?>
|
<?php include 'navbar.php'; ?>
|
||||||
<?php
|
<?php
|
||||||
include 'database.php';
|
include 'database.php';
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<link rel="stylesheet" href="static/style.css" type="text/css" media="screen" />
|
<link rel="stylesheet" href="static/style.css" type="text/css" media="screen" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php include 'navbar.php' ?>
|
<?php include 'navbar.php'; ?>
|
||||||
<div>
|
<div>
|
||||||
<form method="post" action="holiday_management.php">
|
<form method="post" action="holiday_management.php">
|
||||||
<div class="search-group">
|
<div class="search-group">
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<script src="validate_date.js"></script>
|
<script src="validate_date.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php include 'navbar.php' ?>
|
<?php include 'navbar.php'; ?>
|
||||||
<?php
|
<?php
|
||||||
include 'database.php';
|
include 'database.php';
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<link rel="stylesheet" href="static/style.css" type="text/css" media="screen" />
|
<link rel="stylesheet" href="static/style.css" type="text/css" media="screen" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php include 'navbar.php' ?>
|
<?php include 'navbar.php'; ?>
|
||||||
<?php
|
<?php
|
||||||
include 'database.php';
|
include 'database.php';
|
||||||
|
|
||||||
|
|
|
@ -8,24 +8,7 @@
|
||||||
<link rel="stylesheet" href="static/style.css" type="text/css" media="screen" />
|
<link rel="stylesheet" href="static/style.css" type="text/css" media="screen" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<?php include 'navbar.php'; ?>
|
||||||
<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>
|
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<section class="hero">
|
<section class="hero">
|
||||||
<div class="hero-inner">
|
<div class="hero-inner">
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<script src="validate_user.js"></script>
|
<script src="validate_user.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php include 'navbar.php' ?>
|
<?php include 'navbar.php'; ?>
|
||||||
</body>
|
</body>
|
||||||
<form name="login_form" method="post" action="user_management.php" onsubmit="return validateLogin();">
|
<form name="login_form" method="post" action="user_management.php" onsubmit="return validateLogin();">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
<?php session_start(); ?>
|
||||||
<header>
|
<header>
|
||||||
<nav>
|
<nav>
|
||||||
<ul class="navbar-left">
|
<ul class="navbar-left">
|
||||||
|
@ -7,11 +8,15 @@
|
||||||
<li class="list"><a href="patient.php">Pacientes</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="appointment.php">Citas</a></li>
|
||||||
<li class="list"><a href="holiday.php">Vacaciones</a></li>
|
<li class="list"><a href="holiday.php">Vacaciones</a></li>
|
||||||
<?php endif ?>
|
<?php endif; ?>
|
||||||
<?php if($_SESSION["user_type"] == 2): ?>
|
<?php if($_SESSION["user_type"] == 2): ?>
|
||||||
<li class="list"><a href="report.php">Informes</a></li>
|
<li class="list"><a href="report.php">Informes</a></li>
|
||||||
<?php endif ?>
|
<?php endif; ?>
|
||||||
|
<?php if(isset($_SESSION["user"])): ?>
|
||||||
|
<li class="list"><a href="user_management.php?logout=1">Log out</a></li>
|
||||||
|
<?php else: ?>
|
||||||
<li class="list"><a href="login.php">Login</a></li>
|
<li class="list"><a href="login.php">Login</a></li>
|
||||||
|
<?php endif; ?>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<link rel="stylesheet" href="static/style.css" type="text/css" media="screen" />
|
<link rel="stylesheet" href="static/style.css" type="text/css" media="screen" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php include 'navbar.php' ?>
|
<?php include 'navbar.php'; ?>
|
||||||
<div>
|
<div>
|
||||||
<form method="post" action="patient_management.php">
|
<form method="post" action="patient_management.php">
|
||||||
<div class="search-group">
|
<div class="search-group">
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<script src="validate_patient.js"></script>
|
<script src="validate_patient.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php include 'navbar.php' ?>
|
<?php include 'navbar.php'; ?>
|
||||||
<?php
|
<?php
|
||||||
include 'database.php';
|
include 'database.php';
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<link rel="stylesheet" href="static/style.css" type="text/css" media="screen" />
|
<link rel="stylesheet" href="static/style.css" type="text/css" media="screen" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php include 'navbar.php' ?>
|
<?php include 'navbar.php'; ?>
|
||||||
<?php
|
<?php
|
||||||
include 'database.php';
|
include 'database.php';
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<link rel="stylesheet" href="static/style.css" type="text/css" media="screen" />
|
<link rel="stylesheet" href="static/style.css" type="text/css" media="screen" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php include 'navbar.php' ?>
|
<?php include 'navbar.php'; ?>
|
||||||
<div>
|
<div>
|
||||||
<form method="post" action="report_management.php">
|
<form method="post" action="report_management.php">
|
||||||
<div class="search-group">
|
<div class="search-group">
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<script src="validate_report.js"></script>
|
<script src="validate_report.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php include 'navbar.php' ?>
|
<?php include 'navbar.php'; ?>
|
||||||
<?php
|
<?php
|
||||||
include 'database.php';
|
include 'database.php';
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<link rel="stylesheet" href="static/style.css" type="text/css" media="screen" />
|
<link rel="stylesheet" href="static/style.css" type="text/css" media="screen" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php include 'navbar.php' ?>
|
<?php include 'navbar.php'; ?>
|
||||||
<?php
|
<?php
|
||||||
include 'database.php';
|
include 'database.php';
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<link rel="stylesheet" href="static/style.css" type="text/css" media="screen" />
|
<link rel="stylesheet" href="static/style.css" type="text/css" media="screen" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php include 'navbar.php' ?>
|
<?php include 'navbar.php'; ?>
|
||||||
<div>
|
<div>
|
||||||
<form method="post" action="user_management.php">
|
<form method="post" action="user_management.php">
|
||||||
<div class="search-group">
|
<div class="search-group">
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<script src="validate_user.js"></script>
|
<script src="validate_user.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php include 'navbar.php' ?>
|
<?php include 'navbar.php'; ?>
|
||||||
<form name="create_form" method="post" action="user_management.php" onsubmit="return validateUser();">
|
<form name="create_form" method="post" action="user_management.php" onsubmit="return validateUser();">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<label>Nombre</label>
|
<label>Nombre</label>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<link rel="stylesheet" href="static/style.css" type="text/css" media="screen" />
|
<link rel="stylesheet" href="static/style.css" type="text/css" media="screen" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php include 'navbar.php' ?>
|
<?php include 'navbar.php'; ?>
|
||||||
<?php
|
<?php
|
||||||
include 'database.php';
|
include 'database.php';
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
include'database.php';
|
include'database.php';
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
|
||||||
function userCreation(){
|
function userCreation(){
|
||||||
$data = $_POST;
|
$data = $_POST;
|
||||||
$pdo = connectDatabase();
|
$pdo = connectDatabase();
|
||||||
|
@ -42,7 +44,6 @@ function userLogin(){
|
||||||
$db_data = fetchLoginData($pdo, $data);
|
$db_data = fetchLoginData($pdo, $data);
|
||||||
closeDatabase($pdo);
|
closeDatabase($pdo);
|
||||||
if($data["usuario"] == $db_data["usuario"] && $data["contraseña"] == $db_data["contraseña"]){
|
if($data["usuario"] == $db_data["usuario"] && $data["contraseña"] == $db_data["contraseña"]){
|
||||||
session_start();
|
|
||||||
$_SESSION["user"] = $db_data["usuario"];
|
$_SESSION["user"] = $db_data["usuario"];
|
||||||
$_SESSION["user_type"] = $db_data["rol"];
|
$_SESSION["user_type"] = $db_data["rol"];
|
||||||
$location = 'index.php';
|
$location = 'index.php';
|
||||||
|
@ -50,6 +51,15 @@ function userLogin(){
|
||||||
header("location: $location");
|
header("location: $location");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function userLogout(){
|
||||||
|
if(isset($_SESSION["user"])){
|
||||||
|
session_unset();
|
||||||
|
session_destroy();
|
||||||
|
}
|
||||||
|
header("location: index.php");
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_POST["create"])) {
|
if (isset($_POST["create"])) {
|
||||||
userCreation();
|
userCreation();
|
||||||
}
|
}
|
||||||
|
@ -70,3 +80,7 @@ if (isset($_POST["search"])) {
|
||||||
if (isset($_POST["login"])) {
|
if (isset($_POST["login"])) {
|
||||||
userLogin();
|
userLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($_GET["logout"])) {
|
||||||
|
userLogout();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue