prepare("INSERT INTO messages (sender_user_id, recipient_user_id, subject, body) VALUES (?, ?, ?, ?)"); $stmt->execute([$sender_user_id, $recipient_user_id, $subject, $body]); $redirect_url = ($_SESSION['user_role'] === 'staff') ? 'staff_dashboard.php' : 'partner_dashboard.php'; header("Location: " . $redirect_url . "?success=message_sent"); exit; } catch (PDOException $e) { // In a real app, log this error. $redirect_url = ($_SESSION['user_role'] === 'staff') ? 'staff_dashboard.php' : 'partner_dashboard.php'; header("Location: " . $redirect_url . "?error=db_error"); exit; }