html - PHP Contact form, True/False in Email if CheckBox is Checked -
i have file called send_form_email.php , i'm trying send e-mail me trues/falses or way of signifying checkboxes checked. think there's wrong way i've tried expand found on internet - right sends form okay, not information items checked.
these ones checkboxes on web form:
$farmscale = $_post['farmscale']; // not required $nutrients = $_post['nutrients']; // not required $smallscale = $_post['smallscale']; // not required $plantdesign = $_post['plantdesign']; // not required $industrialscale = $_post['industrialscale']; // not required $engineering = $_post['engineering']; // not required $stgs = $_post['stgs']; // not required $compsupply = $_post['compsupply']; // not required
but main file, , i'm not sure how true/fales value spit out in email sends. please gentle... still kinda new stuff.
<?php if(isset($_post['email'])) { // edit 2 lines below required $email_to = "michaelomchenry@gmail.com"; $email_subject = "inquiry enginuityenergy.com"; function died($error) { // error code can go here echo "we sorry, there error(s) found form submitted. "; echo "these errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "please go , fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_post['first_name']) || !isset($_post['last_name']) || !isset($_post['email']) || !isset($_post['telephone']) || !isset($_post['country']) || !isset($_post['comments'])) { died('we sorry, there appears problem form submitted.'); } $first_name = $_post['first_name']; // required $last_name = $_post['last_name']; // required $email_from = $_post['email']; // required $telephone = $_post['telephone']; // not required $country = $_post['country']; // not required $comments = $_post['comments']; // required $farmscale = $_post['farmscale']; // not required $nutrients = $_post['nutrients']; // not required $smallscale = $_post['smallscale']; // not required $plantdesign = $_post['plantdesign']; // not required $industrialscale = $_post['industrialscale']; // not required $engineering = $_post['engineering']; // not required $stgs = $_post['stgs']; // not required $compsupply = $_post['compsupply']; // 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 entered not appear valid.<br />'; } $string_exp = "/^[a-za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'the first name entered not appear valid.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'the last name entered not appear valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'the comments entered not appear 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 .= "first name: ".clean_string($first_name)."\n"; $email_message .= "last name: ".clean_string($last_name)."\n"; $email_message .= "email: ".clean_string($email_from)."\n"; $email_message .= "telephone: ".clean_string($telephone)."\n"; $email_message .= "comments: ".clean_string($comments)."\n"; $email_message .= "country: ".clean_string($country)."\n"; $email_message .= "farm scale: ".$farmscale."\n"; $email_message .= "nutrients: ".$nutrients."\n"; $email_message .= "small scale: ".$smallscale."\n"; $email_message .= "plant design: ".$plantdesign."\n"; $email_message .= "industrial scale: ".$industrialscale."\n"; $email_message .= "engineering: ".$engineering."\n"; $email_message .= "stgs: ".$stgs."\n"; $email_message .= "component supply: ".$compsupply."\n"; // create email headers $headers = 'from: '.$email_from."\r\n". 'reply-to: '.$email_from."\r\n" . 'x-mailer: php/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include own success html here --> <center> <h1>thank contacting us.</h1> <br><br> <p>we in touch soon.</p> <p>in meantime, head <a href="http://www.enginuityenergy.com">main site</a> learn more enginuity energy's innovative biomass gasification.<p> </center> <?php } ?>
i've got on issue inserting new input hidden this:
<input type="hidden" name="farmscale" value="n" /> <input type="checkbox" name="farmscale" value="y" />
you can every checkbox or radio button.
Comments
Post a Comment