I am trying to add check boxes to the standard comment form I always use. Since my code is coming from two different places, I think there is a conflict somewhere. I have never used check boxes.
<tr>
<td valign="top" class="white">
<label for="store_number"> Number of Stores:</label>
</td>
<td valign="top">
<input type="text" name="store_number" maxlength="80" size="50">
</td>
</tr>
<tr>
<td valign="top" class="white"> Type of Business (check all that applies)</td>
<td valign="top">
<label><input type="checkbox" name="businesstype" value="hardware_store">Hardware Store</label><br>
<label><input type="checkbox" name="businesstype" value="hardware_store_with_lumber">Hardware Store with Lumber</label><br>
<label><input type="checkbox" name="businesstype" value="lumber_yard">Lumber Yard</label><br>
<label><input type="checkbox" name="businesstype" value="lumber_yard_with_hardware">Lumber Yard with Hardware</label><br>
<label><input type="checkbox" name="businesstype" value="lawn_garden">Lawn & Garden</label><br>
<label><input type="checkbox" name="businesstype" value="farm_supply">Farm Supply</label><br>
<label><input type="checkbox" name="businesstype" value="other">Other</label>
</td>
</tr>
<tr>
<td valign="top" class="white">
<label for="find_out"> How Did You Find Out About Us:</label>
</td>
<td valign="top">
<input type="text" name="find_out" maxlength="80" size="50">
</td>
</tr>
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['business_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['phone']) ||
!isset($_POST['email']) ||
!isset($_POST['address']) ||
!isset($_POST['po_address']) ||
!isset($_POST['city']) ||
!isset($_POST['state']) ||
!isset($_POST['zip']) ||
!isset($_POST['store_number']) ||
!isset($_POST['find_out']) ||
!isset($_POST['comments'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$business_name = $_POST['business_name']; // required
$last_name = $_POST['last_name']; // required
$phone = $_POST['phone']; // required
$email_from = $_POST['email']; // required
$address = $_POST['address']; // not required
$po_address = $_POST['po_address']; // not required
$city = $_POST['city']; // not required
$state = $_POST['state']; // not required
$zip = $_POST['zip']; // not required
$store_number = $_POST['store_number']; // not required
$businesstype = $_POST['businesstype']; // not required
$find_out = $_POST['find_out']; // not required
$comments = $_POST['comments']; // not required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$business_name)) {
$error_message .= 'The business name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The last name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$phone)) {
$error_message .= 'The phone number you entered does not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Business Name: ".clean_string($business_name)."\n";
$email_message .= "Contact Name: ".clean_string($last_name)."\n";
$email_message .= "Phone: ".clean_string($phone)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "address: ".clean_string($address)."\n";
$email_message .= "po address: ".clean_string($po_address)."\n";
$email_message .= "city: ".clean_string($city)."\n";
$email_message .= "state: ".clean_string($state)."\n";
$email_message .= "zip: ".clean_string($zip)."\n";
$email_message .= "store number: ".clean_string($store_number)."\n";
$email_message .= "Find Out About Us: ".clean_string($find_out)."\n";
$email_message .= "Current Suppliers / Other Comments: ".clean_string($comments)."\n";
$email_message .= $_POST['businesstype'] == "hardware_store" ? "Hardware Store: Yes \n" : "Hardware Store: No \n";
$email_message .= $_POST['businesstype'] == "hardware_store_with_lumber" ? "Hardware Store With Lumber: Yes \n" : "Hardware Store With Lumber: No \n";
$email_message .= $_POST['businesstype'] == "lumber_yard" ? "Lumber Yard: Yes \n" : "Lumber Yard: No \n";
$email_message .= $_POST['businesstype'] == "lumber_yard_with_hardware" ? "Lumber Yard With Hardware: Yes \n" : "Lumber Yard With Hardware: No \n";
$email_message .= $_POST['businesstype'] == "lawn_garden" ? "Lawn Garden: Yes \n" : "Lawn Garden: No \n";
$email_message .= $_POST['businesstype'] == "farm_supply" ? "Farm Supply: Yes \n" : "Farm Supply: No \n";
$email_message .= $_POST['businesstype'] == "other" ? "Other: Yes \n" : "Other: No \n";
Congratulations! We’ve successfully received your application and will be reviewing it right away. Please expect to hear from a highly qualified xxxxx representative soon. Thank you!<br><br>
<a href="http://www.xxxxx.com">Return to our website</a>.
<?php
}
?>
Bookmarks