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