141 lines
5.9 KiB
PHP
141 lines
5.9 KiB
PHP
<?php
|
|
session_start();
|
|
require_once 'db/config.php';
|
|
|
|
$message = '';
|
|
|
|
// Create hospitals table if it doesn't exist
|
|
try {
|
|
$pdo = db();
|
|
$sql = "CREATE TABLE IF NOT EXISTS hospitals (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
hospital_name VARCHAR(255) NOT NULL,
|
|
email VARCHAR(255) NOT NULL UNIQUE,
|
|
password VARCHAR(255) NOT NULL,
|
|
phone VARCHAR(50),
|
|
address TEXT,
|
|
registration_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
status VARCHAR(50) DEFAULT 'pending_verification'
|
|
)";
|
|
$pdo->exec($sql);
|
|
} catch (PDOException $e) {
|
|
die("Could not create table: " . $e->getMessage());
|
|
}
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
$hospital_name = trim($_POST['hospital_name']);
|
|
$email = trim($_POST['email']);
|
|
$password = $_POST['password'];
|
|
$phone = trim($_POST['phone']);
|
|
$address = trim($_POST['address']);
|
|
|
|
if (empty($hospital_name) || empty($email) || empty($password)) {
|
|
$message = '<div class="alert alert-danger">Please fill in all required fields.</div>';
|
|
} else {
|
|
try {
|
|
$pdo = db();
|
|
// Check if email already exists
|
|
$stmt = $pdo->prepare("SELECT id FROM hospitals WHERE email = ?");
|
|
$stmt->execute([$email]);
|
|
if ($stmt->fetch()) {
|
|
$message = '<div class="alert alert-danger">This email address is already registered.</div>';
|
|
} else {
|
|
// Hash the password
|
|
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
|
|
|
|
$sql = "INSERT INTO hospitals (hospital_name, email, password, phone, address) VALUES (?, ?, ?, ?, ?)";
|
|
$stmt = $pdo->prepare($sql);
|
|
$stmt->execute([$hospital_name, $email, $hashed_password, $phone, $address]);
|
|
$message = '<div class="alert alert-success">Hospital registered successfully! You will be able to log in once the admin verifies your account.</div>';
|
|
}
|
|
} catch (PDOException $e) {
|
|
$message = '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Hospital Registration - Organ Donation Management System</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css">
|
|
</head>
|
|
<body>
|
|
|
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
|
<div class="container-fluid">
|
|
<a class="navbar-brand" href="index.php">OrganDonation</a>
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navbarNav">
|
|
<ul class="navbar-nav ms-auto">
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="index.php">Home</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="donor_register.php">Become a Donor</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link btn btn-primary text-white" href="hospital_register.php">Hospital Registration</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="hospital_login.php">Hospital Login</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="container mt-5">
|
|
<div class="row justify-content-center">
|
|
<div class="col-md-8">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h2>Hospital Registration</h2>
|
|
<p>Register your hospital to manage recipient information.</p>
|
|
</div>
|
|
<div class="card-body">
|
|
<?php if (!empty($message)) echo $message; ?>
|
|
<form action="hospital_register.php" method="post">
|
|
<div class="mb-3">
|
|
<label for="hospital_name" class="form-label">Hospital Name</label>
|
|
<input type="text" class="form-control" id="hospital_name" name="hospital_name" required>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="email" class="form-label">Email address</label>
|
|
<input type="email" class="form-control" id="email" name="email" required>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="password" class="form-label">Password</label>
|
|
<input type="password" class="form-control" id="password" name="password" required>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="phone" class="form-label">Phone Number</label>
|
|
<input type="tel" class="form-control" id="phone" name="phone">
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="address" class="form-label">Address</label>
|
|
<textarea class="form-control" id="address" name="address" rows="3"></textarea>
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-primary">Register</button>iv>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<footer class="bg-dark text-white text-center p-3 mt-5">
|
|
<p>© 2025 Organ Donation Management System. All Rights Reserved.</p>
|
|
</footer>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script src="assets/js/main.js"></script>
|
|
</body>
|
|
</html>
|