Welcome, !
Your role:
prepare("UPDATE doctors SET availability = ? WHERE id = ?"); $stmt->execute([$availability, $doctorId]); header("Location: dashboard.php"); // Redirect to avoid form resubmission exit; } catch (PDOException $e) { // For simplicity, we are not displaying the error here. In a real application, you would log this. } } if (!isset($_SESSION['user_id'])) { header("Location: login.php"); exit; } $userName = $_SESSION['user_name'] ?? 'User'; $userRole = $_SESSION['user_role'] ?? 'guest'; // Content for different roles $dashboardContent = ''; switch ($userRole) { case 'superadmin': $dashboardContent = '
Here you can manage the entire application, including admins, hospitals, doctors, and patients.
'; break; case 'admin': $dashboardContent = 'Here you can manage hospitals, doctors, and patients.
'; break; case 'hospital': $dashboardContent = 'Here you can manage your hospital profile, treatments, and doctors.
'; break; case 'doctor': $db = db(); $doctorId = $_SESSION['user_id']; // Fetch doctor's complete profile $stmt = $db->prepare("SELECT d.full_name, d.email, d.specialty, d.qualifications, d.specialities, d.contact_phone, d.license_number, d.consultation_fee, d.availability, h.hospital_name, h.address, h.city, h.state, h.country FROM doctors d LEFT JOIN hospitals h ON d.hospital_id = h.id WHERE d.id = ?"); $stmt->execute([$doctorId]); $doctor = $stmt->fetch(PDO::FETCH_ASSOC); $profileInfo = 'Name: '.htmlspecialchars($doctor['full_name']).'
'; $profileInfo .= 'Email: '.htmlspecialchars($doctor['email']).'
'; $profileInfo .= 'Contact Phone: '.htmlspecialchars($doctor['contact_phone']).'
'; $profileInfo .= 'Primary Specialty: '.htmlspecialchars($doctor['specialty']).'
'; $profileInfo .= 'Additional Specialities: '.nl2br(htmlspecialchars($doctor['specialities'])).'
'; $profileInfo .= 'Qualifications: '.nl2br(htmlspecialchars($doctor['qualifications'])).'
'; $profileInfo .= 'License Number: '.htmlspecialchars($doctor['license_number']).'
'; $profileInfo .= 'Consultation Fee: case 'patient': $dashboardContent = '
Here you can manage your profile, view your medical history, and book appointments.
'; break; default: $dashboardContent = 'Welcome to your dashboard.
'; break; } ?>Your role:
Availability: '.nl2br(htmlspecialchars($doctor['availability'])).'
'; } else { $profileInfo .= 'Profile not found.
'; } $profileInfo .= ''.htmlspecialchars($doctor['hospital_name']).'
'; $hospitalInfo .= ''.htmlspecialchars($doctor['address']).', '.htmlspecialchars($doctor['city']).', '.htmlspecialchars($doctor['state']).', '.htmlspecialchars($doctor['country']).'
'; } else { $hospitalInfo .= 'You are not currently affiliated with any hospital.
'; } $hospitalInfo .= 'No patient history found.
'; } $patientHistory .= 'Here you can manage your profile, view your medical history, and book appointments.
'; break; default: $dashboardContent = 'Welcome to your dashboard.
'; break; } ?>Your role: