exec("CREATE TABLE IF NOT EXISTS patients ( id INT AUTO_INCREMENT PRIMARY KEY, full_name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL UNIQUE, password VARCHAR(255) NOT NULL, dob DATE, passport_id_path VARCHAR(255), contact_number VARCHAR(50), emergency_contact VARCHAR(50), medical_history TEXT, insurance_info VARCHAR(255), created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP )"); // File upload handling $passport_id_path = null; if (isset($_FILES['passportId']) && $_FILES['passportId']['error'] == UPLOAD_ERR_OK) { $upload_dir = 'uploads/passports/'; $file_name = uniqid() . '-' . basename($_FILES['passportId']['name']); $passport_id_path = $upload_dir . $file_name; if (!move_uploaded_file($_FILES['passportId']['tmp_name'], $passport_id_path)) { throw new Exception("Failed to upload passport/ID file."); } } // Hash password $password_hash = password_hash($_POST['password'], PASSWORD_DEFAULT); // Insert data $stmt = $pdo->prepare( "INSERT INTO patients (full_name, email, password, dob, passport_id_path, contact_number, emergency_contact, medical_history, insurance_info) VALUES (:full_name, :email, :password, :dob, :passport_id_path, :contact_number, :emergency_contact, :medical_history, :insurance_info)" ); $stmt->bindParam(':full_name', $_POST['fullName']); $stmt->bindParam(':email', $_POST['email']); $stmt->bindParam(':password', $password_hash); $stmt->bindParam(':dob', $_POST['dob']); $stmt->bindParam(':passport_id_path', $passport_id_path); $stmt->bindParam(':contact_number', $_POST['contactNumber']); $stmt->bindParam(':emergency_contact', $_POST['emergencyContact']); $stmt->bindParam(':medical_history', $_POST['medicalHistory']); $stmt->bindParam(':insurance_info', $_POST['insuranceInfo']); $stmt->execute(); $success_message = "Registration successful! You can now log in."; } 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(); } } ?> Patient Registration - Medicaltour

Patient Registration

Create your account to access our services.