I am having the hardest time trying to debug this script. I have a contact form that has several text box fields and one <select multiple> box. The text box processes through the script but the <select multiple> does not.
I am trying to email an array of sorts. When a user selects two choices on the list of choices, I want the email to show this:
Name: name variable
Company: company variable
Email: email variable
Phone Number: phone variable
Inquiry: inquiry variable
but on the inquiry variable, I want it separated with </br>'s.
Here's my code - redacted:
- Code: Select all
<?
$name = $_POST['name'];
$company = $_POST['company'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$inquiry = $_POST['inquiry'];
$to = "myemail";
/* subject */
$subject = "Contact Form";
/* message */
$message= "
<strong>Contact Form</strong><br><br>
<strong>Name:</strong> $name<br>
<strong>Company:</strong> $company<br>
<strong>Phone:</strong> $phone<br>
<strong>Email:</strong> $email<br>
foreach ($inquiry as $i) {
echo "
<strong>Inquiry:</strong> $i<br>";
}
";
/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
/* additional headers */
$headers .= "To: Me <myemail>\r\n";
$headers .= "From: Contact Form <contactform@myemail>\r\n";
mail($to, $subject, $message, $headers);
?>
Can someone find a way for the inquiry variables to be separated using breaks and still look good on the email form?
Regards,
Chris

