How can PHP variables be correctly assigned and used to include form data in email messages?

When including form data in email messages using PHP, variables need to be correctly assigned to capture the form input values. This can be achieved by using the $_POST superglobal array to retrieve the form data and assign it to variables. These variables can then be included in the email message using concatenation or interpolation.

// Assign form input values to variables
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];

// Create email message with form data
$email_message = "Name: $name\nEmail: $email\nMessage: $message";

// Send email
mail('recipient@example.com', 'Contact Form Submission', $email_message);