How can the PHP code be modified to ensure that only the logged-in user who clicked "send" receives the email?

To ensure that only the logged-in user who clicked "send" receives the email, you can modify the PHP code to retrieve the email address of the logged-in user from the session data and use it as the recipient of the email. This way, the email will only be sent to the user who initiated the action.

<?php
session_start();

if(isset($_POST['send'])) {
    // Retrieve the email address of the logged-in user from session data
    $recipient_email = $_SESSION['user_email'];

    // Rest of the email sending code
    // Use $recipient_email as the recipient of the email
}
?>