What is the common issue when trying to redirect to a confirmation page after sending an email in PHP?

The common issue when trying to redirect to a confirmation page after sending an email in PHP is that the headers have already been sent by the time the redirection code is executed. To solve this issue, you can use output buffering to capture the output before sending any headers.

<?php
ob_start(); // Start output buffering

// Your email sending code here

ob_end_clean(); // Clean the output buffer
header('Location: confirmation.php'); // Redirect to confirmation page
exit;
?>