108 lines
4.6 KiB
PHP
108 lines
4.6 KiB
PHP
<?php
|
|
session_start();
|
|
require_once 'db/config.php';
|
|
|
|
$error = '';
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
$email = trim($_POST['email']);
|
|
$password = $_POST['password'];
|
|
|
|
if (empty($email) || empty($password)) {
|
|
$error = "Email and password are required.";
|
|
} else {
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare("SELECT * FROM hospitals WHERE email = ?");
|
|
$stmt->execute([$email]);
|
|
$hospital = $stmt->fetch();
|
|
|
|
if ($hospital && password_verify($password, $hospital['password_hash'])) {
|
|
if ($hospital['status'] == 'Verified') {
|
|
$_SESSION['hospital_id'] = $hospital['id'];
|
|
$_SESSION['hospital_name'] = $hospital['name'];
|
|
header("Location: hospital_dashboard.php");
|
|
exit;
|
|
} else {
|
|
$error = "Your hospital account is not yet verified.";
|
|
}
|
|
} else {
|
|
$error = "Invalid email or password.";
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Hospital Login - Organ Donation</title>
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
<style>
|
|
body {
|
|
font-family: 'Poppins', sans-serif;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body class="bg-gray-100">
|
|
|
|
<nav class="bg-white shadow-md">
|
|
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
|
<div class="flex justify-between h-16">
|
|
<div class="flex">
|
|
<a href="index.php" class="flex-shrink-0 flex items-center">
|
|
<span class="font-bold text-xl text-blue-600">OrganConnect</span>
|
|
</a>
|
|
</div>
|
|
<div class="flex items-center">
|
|
<a href="index.php" class="px-3 py-2 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-200">Home</a>
|
|
<a href="donor_registration.php" class="px-3 py-2 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-200">Become a Donor</a>
|
|
<a href="hospital_registration.php" class="px-3 py-2 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-200">Hospital Registration</a>
|
|
<a href="hospital_login.php" class="px-3 py-2 rounded-md text-sm font-medium text-blue-600 bg-blue-100">Hospital Portal</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="container mx-auto px-4 py-12">
|
|
<div class="max-w-md mx-auto bg-white p-8 rounded-lg shadow-lg">
|
|
<h1 class="text-3xl font-bold text-center text-gray-800 mb-6">Hospital Login</h1>
|
|
|
|
<?php if ($error): ?>
|
|
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative mb-4" role="alert">
|
|
<span class="block sm:inline"><?php echo htmlspecialchars($error); ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<form action="hospital_login.php" method="POST" class="space-y-6">
|
|
<div>
|
|
<label for="email" class="block text-sm font-medium text-gray-700">Email Address</label>
|
|
<input type="email" name="email" id="email" required class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm">
|
|
</div>
|
|
<div>
|
|
<label for="password" class="block text-sm font-medium text-gray-700">Password</label>
|
|
<input type="password" name="password" id="password" required class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm">
|
|
</div>
|
|
<div>
|
|
<button type="submit" class="w-full flex justify-center py-3 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
|
|
Login
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<footer class="bg-white fixed bottom-0 w-full">
|
|
<div class="max-w-7xl mx-auto py-4 px-4 sm:px-6 lg:px-8">
|
|
<div class="flex justify-between items-center">
|
|
<p class="text-center text-gray-500 text-sm">© <?php echo date("Y"); ?> OrganConnect. All rights reserved.</p>
|
|
<a href="admin/" class="text-sm text-gray-500 hover:text-gray-700">Admin Login</a>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
|
|
</body>
|
|
</html>
|