i keep getting an error:
Warning: Invalid argument supplied for foreach() in /home/content/p/a/r/paramexdesign/html/pv/mailer.php on line 16
Msg seems to be sending but for some weird reason keeps giving me this error msg only when I select the floor plans etc. you can test out the code here:
http://paramexdesign.com/pv/contactus-test3.html
Here are the codes (note form is build with form dependency):
<?php
if(isset($_POST['submit'])) {
$to = "tharanp@gmail.com";
$option = $_POST['subject'];
$subject = "$option - University Trails Prairie View";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$phone_field = $_POST['phone'];
$message = $_POST['message'];
$drop_downhearus = $_POST['drop_down-hearus'];
$drop_downbathroom = $_POST['drop_down-bathroom'];
$drop_downbedroom = $_POST['drop_down-bedroom'];
$checklease_msg = $_POST['check-lease'];
foreach($_POST['check-floor'] as $value1) {
$check_msg .= "$value1
";
}
foreach($_POST['general-subject'] as $value2) {
$generalsubject_msg .= "$value2
";
}
$body = "
$generalsubject_msg
From: $name_field
Subject: $option
E-Mail: $email_field
Phone: $phone_field
Floor Plan Perference(s):
$check_msg
Desired Lease Length: $checklease_msg
Desired Bedroom(s): $drop_downbedroom
Desired Bathroom(s): $drop_downbathroom
User heard about us through: $drop_downhearus
Questions or Comments:
$message
";
echo "Data has been submitted to $to!";
mail($to, $subject, $body);
} else {
echo "blarg!";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="scripts/FormManager.js">
</script>
<script type="text/javascript">
window.onload = function() {
setupDependencies('weboptions'); //name of form(s). Seperate each with a comma (ie: 'weboptions', 'myotherform' )
};
</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
<form method="POST" action="mailer.php" name="weboptions">
Name (First/Last):
<input type="text" name="name" size="19"><br>
<br>
Your Email Address:
<input type="text" name="email" size="19"><br>
<br>
Phone:
<input type="text" name="phone" size="19"><br>
<br>
<label>General Inquiry<input type="radio" name="subject" value="General-Inquiry"></label>
<label>Schedule A Visit<input type="radio" name="subject" value="Schedule-A-Visit"></label>
<label>Maintenance Request<input type="radio" name="subject" value="Maintenance"></label>
<label><br />Subject:<input type="text" name="general-subject[]" class="DEPENDS ON subject BEING General-Inquiry"></label>
<br /><br />
<label>Message:<br>
<textarea rows="9" name="message" cols="30" class="DEPENDS ON subject BEING Schedule-A-Visit OR subject BEING General-Inquiry OR subject BEING Maintenance"></textarea></label><br>
<br>
<label>Floor Plan Perference:<br>
<input type="checkbox" name="check-floor[]" value="2x2" class="DEPENDS ON subject BEING Schedule-A-Visit"> 2x2<br>
<input type="checkbox" name="check-floor[]" value="3x3" class="DEPENDS ON subject BEING Schedule-A-Visit"> 3x3<br>
<input type="checkbox" name="check-floor[]" value="4x2" class="DEPENDS ON subject BEING Schedule-A-Visit"> 4x2<br>
<br /></label>
<label>Desired Lease Length:
<input type="checkbox" name="check-lease" value="12 Months" class="DEPENDS ON subject BEING Schedule-A-Visit">12 Months</label>
<br />
<br>
<label>Desired Bathroom:
<select size="1" name="drop_down-bathroom" class="DEPENDS ON subject BEING Schedule-A-Visit">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7+</option>
</select></label><br /><br />
<label>Desired Bedroom:<select size="1" name="drop_down-bedroom" class="DEPENDS ON subject BEING Schedule-A-Visit">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7+</option>
</select></label><br><br>
<label>How did you first hear about us?<br><select size="1" name="drop_down-hearus" class="DEPENDS ON subject BEING Schedule-A-Visit OR subject BEING General-Inquiry">
<option>Signs/Drive By</option>
<option>Search Engine (Google, Yahoo! etc.)</option>
<option>Social Media Networks (Facebook, Twitter..)</option>:
<option>Craiglist, Kijiji</option>
<option>CollegeRentals.com</option>
<option>Other Internet Sites</option>
<option>Housing Fair</option>
<option>Friend</option>
<option>Student Newspaper</option>
<option>Apartment Publication</option>
<option>Employee</option>
<option>Other</option>
</select></label><br><br>
<br>
<br>
<input type="submit" value="Submit" name="submit">
</form>
</body>
</html>