How can all form data, including file uploads and text, be displayed in an email using PHP?

To display all form data, including file uploads and text, in an email using PHP, you can use the $_POST and $_FILES superglobals to access the form data and uploaded files respectively. You can then loop through these arrays to construct the email message with all the form data included.

// Get form data
$formData = $_POST;

// Get uploaded files
$uploadedFiles = $_FILES;

// Construct email message
$message = "Form Data:\n";
foreach ($formData as $key => $value) {
    $message .= $key . ": " . $value . "\n";
}

$message .= "\nUploaded Files:\n";
foreach ($uploadedFiles as $file) {
    $message .= "File Name: " . $file['name'] . "\n";
    $message .= "File Type: " . $file['type'] . "\n";
    $message .= "File Size: " . $file['size'] . " bytes\n";
}

// Send email
$to = "recipient@example.com";
$subject = "Form Data";
$headers = "From: sender@example.com";
mail($to, $subject, $message, $headers);