diff --git a/add_patient.php b/add_patient.php index a20e19c..3ac642e 100644 --- a/add_patient.php +++ b/add_patient.php @@ -1,8 +1,16 @@ false, 'message' => 'Unauthorized']); + exit; +} + $response = ['success' => false, 'message' => 'An error occurred.']; if ($_SERVER['REQUEST_METHOD'] === 'POST') { diff --git a/auth.php b/auth.php new file mode 100644 index 0000000..1f2430d --- /dev/null +++ b/auth.php @@ -0,0 +1,54 @@ +prepare("SELECT * FROM users WHERE username = :username"); + $stmt->bindParam(':username', $username); + $stmt->execute(); + $user = $stmt->fetch(PDO::FETCH_ASSOC); + + if ($user && password_verify($password, $user['password'])) { + // Regenerate session ID to prevent session fixation + session_regenerate_id(true); + + // Store user data in session + $_SESSION['user_id'] = $user['id']; + $_SESSION['username'] = $user['username']; + $_SESSION['role'] = $user['role']; + + // Redirect based on role + if ($user['role'] === 'admin') { + header('Location: dashboard.php'); + } else { + // Redirect to a general user page or index if not admin + header('Location: index.php'); + } + exit; + } else { + $_SESSION['error'] = 'Usuario o contraseña incorrectos.'; + header('Location: login.php'); + exit; + } +} catch (PDOException $e) { + // In a real app, log this error instead of showing it to the user + $_SESSION['error'] = 'Error de base de datos. Intente de nuevo más tarde.'; + // error_log($e->getMessage()); + header('Location: login.php'); + exit; +} diff --git a/dashboard.php b/dashboard.php new file mode 100644 index 0000000..929d9ce --- /dev/null +++ b/dashboard.php @@ -0,0 +1,43 @@ + + + + + + + Dashboard - CDT Health Care + + + + + + +
+
+
+

Bienvenido,

+

Este es el panel de administración. Desde aquí podrás gestionar usuarios, ver reportes y configurar el sistema.

+
+
+
+ + diff --git a/index.php b/index.php index 840cc8e..28f6f69 100644 --- a/index.php +++ b/index.php @@ -1,13 +1,23 @@ + - SdC - Patient Transfer - - - - + CDT Health Care - Patient Transfer + + + + @@ -15,6 +25,25 @@ +

Patient Transfer Request

@@ -65,6 +94,7 @@ + \ No newline at end of file diff --git a/login.php b/login.php new file mode 100644 index 0000000..c462e81 --- /dev/null +++ b/login.php @@ -0,0 +1,42 @@ + + + + + + + Login - CDT Health Care + + + + +
+
+
+

Iniciar Sesión

+ + + +
+
+ + +
+
+ + +
+
+ +
+
+
+
+
+ + diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..c2d0fec --- /dev/null +++ b/logout.php @@ -0,0 +1,12 @@ +