exec("CREATE TABLE IF NOT EXISTS hospitals ( id INT AUTO_INCREMENT PRIMARY KEY, hospital_name VARCHAR(255) NOT NULL, address VARCHAR(255), contact_person VARCHAR(255), contact_email VARCHAR(255) NOT NULL UNIQUE, password VARCHAR(255) NOT NULL, specialties TEXT, accreditation_path VARCHAR(255), billing_details TEXT, subscription_plan VARCHAR(50), logo_path VARCHAR(255), gallery_paths TEXT, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP )"); // File upload handling $upload_dir = 'uploads/hospitals/'; $accreditation_path = null; if (isset($_FILES['accreditation']) && $_FILES['accreditation']['error'] == UPLOAD_ERR_OK) { $file_name = uniqid() . '-accreditation-' . basename($_FILES['accreditation']['name']); $accreditation_path = $upload_dir . $file_name; if (!move_uploaded_file($_FILES['accreditation']['tmp_name'], $accreditation_path)) { throw new Exception("Failed to upload accreditation file."); } } $logo_path = null; if (isset($_FILES['logo']) && $_FILES['logo']['error'] == UPLOAD_ERR_OK) { $file_name = uniqid() . '-logo-' . basename($_FILES['logo']['name']); $logo_path = $upload_dir . $file_name; if (!move_uploaded_file($_FILES['logo']['tmp_name'], $logo_path)) { throw new Exception("Failed to upload logo file."); } } $gallery_paths = []; if (isset($_FILES['gallery']['name']) && is_array($_FILES['gallery']['name'])) { foreach ($_FILES['gallery']['tmp_name'] as $key => $tmp_name) { if ($_FILES['gallery']['error'][$key] == UPLOAD_ERR_OK) { $file_name = uniqid() . '-gallery-' . basename($_FILES['gallery']['name'][$key]); $gallery_path = $upload_dir . $file_name; if (move_uploaded_file($tmp_name, $gallery_path)) { $gallery_paths[] = $gallery_path; } } } } $gallery_paths_json = json_encode($gallery_paths); // Hash password $password_hash = password_hash($_POST['password'], PASSWORD_DEFAULT); // Insert data $stmt = $pdo->prepare( "INSERT INTO hospitals (hospital_name, address, contact_person, contact_email, password, specialties, accreditation_path, billing_details, subscription_plan, logo_path, gallery_paths) VALUES (:hospital_name, :address, :contact_person, :contact_email, :password, :specialties, :accreditation_path, :billing_details, :subscription_plan, :logo_path, :gallery_paths)" ); $stmt->bindParam(':hospital_name', $_POST['hospitalName']); $stmt->bindParam(':address', $_POST['address']); $stmt->bindParam(':contact_person', $_POST['contactPerson']); $stmt->bindParam(':contact_email', $_POST['contactEmail']); $stmt->bindParam(':password', $password_hash); $stmt->bindParam(':specialties', $_POST['specialties']); $stmt->bindParam(':accreditation_path', $accreditation_path); $stmt->bindParam(':billing_details', $_POST['billingDetails']); $stmt->bindParam(':subscription_plan', $_POST['subscriptionPlan']); $stmt->bindParam(':logo_path', $logo_path); $stmt->bindParam(':gallery_paths', $gallery_paths_json); $stmt->execute(); $success_message = "Registration successful! Your hospital profile will be reviewed shortly."; } catch (PDOException $e) { if ($e->getCode() == 23000) { // Integrity constraint violation (duplicate entry) $error_message = "An account with this email address already exists."; } else { $error_message = "Database error: " . $e->getMessage(); } } catch (Exception $e) { $error_message = "An error occurred: " . $e->getMessage(); } } ?> Hospital Registration - Medicaltour

Hospital Registration

Register your hospital to be part of our exclusive network.