exec("ALTER TABLE `doctors` ADD COLUMN IF NOT EXISTS `hospital_id` INT NULL AFTER `id`, ADD INDEX (`hospital_id`);"); // Handle form submission to add a new doctor if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['email'])) { $fullName = $_POST['full_name']; $email = $_POST['email']; $password = password_hash($_POST['password'], PASSWORD_DEFAULT); if (!empty($email) && !empty($fullName) && !empty($_POST['password'])) { $stmt = $pdo->prepare("INSERT INTO doctors (hospital_id, full_name, email, password, status) VALUES (:hospital_id, :full_name, :email, :password, 'active')"); $stmt->bindParam(':hospital_id', $hospitalId, PDO::PARAM_INT); $stmt->bindParam(':full_name', $fullName, PDO::PARAM_STR); $stmt->bindParam(':email', $email, PDO::PARAM_STR); $stmt->bindParam(':password', $password, PDO::PARAM_STR); if ($stmt->execute()) { $message = '
Doctor added successfully!
'; } else { $message = '
Failed to add doctor. The email might already be registered.
'; } } else { $message = '
Please fill all required fields.
'; } } // Fetch existing doctors for this hospital $stmt = $pdo->prepare("SELECT id, full_name, email, specialty FROM doctors WHERE hospital_id = :hospital_id ORDER BY full_name"); $stmt->bindParam(':hospital_id', $hospitalId, PDO::PARAM_INT); $stmt->execute(); $doctors = $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { $message = '
Database error: ' . $e->getMessage() . '
'; $doctors = []; } ?> Manage Doctors - Medicaltour

Manage Doctors

Add New Doctor
Your Doctors

You have not added any doctors yet.

Name Email Specialty