exec($sql); } catch (PDOException $e) { die("Could not create table: " . $e->getMessage()); } $message = ''; $error = ''; if ($_SERVER["REQUEST_METHOD"] == "POST") { // Collect and sanitize input $name = trim($_POST['name']); $license_number = trim($_POST['license_number']); $address = trim($_POST['address']); $phone = trim($_POST['phone']); $email = trim($_POST['email']); $password = $_POST['password']; $has_transplant_capability = isset($_POST['has_transplant_capability']) ? 1 : 0; // Validation if (empty($name) || empty($license_number) || empty($address) || empty($phone) || empty($email) || empty($password)) { $error = "All fields except transplant capability are required."; } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $error = "Invalid email format."; } else { // Check if email already exists $stmt = $pdo->prepare("SELECT id FROM hospitals WHERE email = ?"); $stmt->execute([$email]); if ($stmt->fetch()) { $error = "This email address is already registered."; } else { // Hash password and insert data $password_hash = password_hash($password, PASSWORD_DEFAULT); $sql = "INSERT INTO hospitals (name, license_number, address, phone, email, password_hash, has_transplant_capability) VALUES (?, ?, ?, ?, ?, ?, ?)"; $stmt = $pdo->prepare($sql); try { $stmt->execute([$name, $license_number, $address, $phone, $email, $password_hash, $has_transplant_capability]); $message = "Registration successful! Your application is pending verification from an administrator."; } catch (PDOException $e) { $error = "Error: " . $e->getMessage(); } } } } ?> Hospital Registration - Organ Donation

Hospital Registration