What is the correct syntax for sending an email with multiple input fields in PHP?
When sending an email with multiple input fields in PHP, you need to properly format the email content to include all the input fields. One way to achieve this is by concatenating the values of the input fields into the email body. You can use the PHP `$_POST` superglobal to retrieve the values of the input fields and include them in the email.
<?php
// Retrieve input field values
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
// Set up email content
$to = 'recipient@example.com';
$subject = 'New message from contact form';
$body = "Name: $name\n";
$body .= "Email: $email\n";
$body .= "Message: $message";
// Send email
mail($to, $subject, $body);
?>
Related questions
-
PHP MySQL database
-
security vulnerabilities encryption license key validation
-
PHP variable passing settings