Hi everyone! I’m having a problem with my php mailer. It’s giving me an error after I submit it, but the email does get to me though. Help please! This is the error I’m getting: “Warning: Invalid argument supplied for foreach() in e:\web\public_html\experimenatl\Experimental\mailer.php on line 35”
Here’s the code:
<?php
if(isset($_POST['submit'])) {
$rey = "email";
$to = "email@email.com";
$subject = "Mail";
$name_field = $_POST['name'];
$last_field = $_POST['last'];
$address_field = $_POST['address'];
$city_field = $_POST['city'];
$state_field = $_POST['state'];
$code_field = $_POST['code'];
$phone_field = $_POST['phone'];
$email_field = $_POST['email'];
$check = $_POST['call'];
$checkb = $_POST['brochure'];
$message = $_POST['message'];
$us = $_POST['us'];
$friend = $_POST['friend'];
$ad = $_POST['ad'];
$article = $_POST['article'];
$internet = $_POST['internet'];
$mail = $_POST['mail'];
$other = $_POST['other'];
$hearOther = $_POST['hearOther'];
foreach($_POST['check'] as $value) {
$check_msg .= "Checked: $value
";
}
$body = "From: $name_field
Last Name: $last_field
Address: $address_field
City: $city_field
State: $state_field
Postal Code: $code_field
Email: $email_field
Call: $check
Brochure: $checkb
Questions/Comments: $message
How did you hear about us: $us
Friend: $friend
Ad: $ad
Article: $article
Internet: $internet
Mail: $mail
Other: $other
Other description: $hearOther
";
echo "Data has been submitted to $rey!";
$header = 'From: info@email.com' . "
" .
'Reply-To: info@email.com' . "
" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $body, $header);
} else {
echo "Please go to contact page if you need to contact us";
}
?>
<br /><br />
<a href="contact.php"> Back to Contact Page </a>