Create an array with each POST value, looping through them and checking if they're filled out should work.
PHP Code:
<?php
$to = "josh@gscapedesign.com";
$subject = "Greenscape Customer Inquiry";
$message = "Customer name: " . $_POST['name'] . "\r\n" .
"Phone number: " . $_POST['phone'] . "\r\n" .
"Email: " . $_POST['email'] . "\r\n" ."\r\n" .
"Contact: " . $_POST['contact'] . "\r\n" ."\r\n";
$field = array('landscape design and construction', 'hardscape design and construction', 'grounds maintenance', 'irrigation and drainage systems', 'lighting', 'budget');
foreach($field as $f) {
if($_POST[$f] != '' && isset($_POST[$f])) {
$message .= "Services: ".$_POST[$f]."\r\n";
}
}
$message .= "Budget: " . $_POST['budget'] . "\r\n" .
$from = $_POST['email'];
$headers = "From: $from" . "\r\n";
$headers = "Bcc: kroge16@tigers.lsu.edu" . "\r\n" ;
mail($to,$subject,$message,$headers) ;
?>
Bookmarks