Hi,
I am having some trouble with my php code for my email form. When I submit the form, I get no email in return. Or when I hit the submit the form blank, no error page comes up stating what should be required to be completed. Is there anyway someone could take a look at it and offer any type of assistance? I’d appreciate it a lot.
Thanks so much in advance.
My form coding for the html page:
<!DOCTYPE html>
<html>
<head>
<title>
Business Card Form
</title>
<!-- Meta Tags -->
<meta charset="utf-8">
<!-- CSS -->
<link rel="stylesheet" href="css/structure.css" type="text/css" />
<link rel="stylesheet" href="css/form.css" type="text/css" />
<!-- JavaScript -->
<script src="scripts/vinet.js"></script>
<!--[if lt IE 10]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style type="text/css">
<!--
.style1 {color: #000000}
.style2 {color: #000000}
-->
</style>
</head>
<body id="public">
<div id="container" class="ltr">
<img src="vinet.png">
<form id="form67" name="form67" class="wufoo topLabel page" autocomplete="off" enctype="multipart/form-data" method="post" novalidate
action="send_form_email.php">
<header id="header" class="info">
<h2 align="center">Sign up for a Business Card</h2>
<p align="center">Fields marked with <span class="style1">*</span> are required.</p>
<div>
<div align="center" class="style2">Please note that all information inputed will effectively be added to your order.</div>
</div>
</header>
<ul>
<li id="foli3" class="leftHalf ">
<label class="desc" id="title3" for="Field3">
Name
<span id="req_3" class="req">*</span></label>
<span>
<input id="Field3" name="Field3" type="text" class="field text fn" value="" size="10" tabindex="4" required />
<label for="Field3">First</label>
</span>
<span>
<input id="Field4" name="Field4" type="text" class="field text ln" value="" size="14" tabindex="5" required />
<label for="Field4">Last</label>
</span></li>
<li id="foli11" class="rightHalf ">
<label class="desc" id="title4" for="Field11">
Rank (Company Position)
<span id="req_11" class="req">*</span></label>
<div>
<input id="Field11" name="Field11" type="text" class="field text medium" value="" tabindex="5" required />
</div>
</li>
<li id="foli11" class="rightHalf ">
<label class="desc" id="title5" for="Field11">
Fax Number
</label>
<div>
<input id="Field11" name="Field11" type="text" class="field text medium" value="" tabindex="5" >
</div>
</li>
<li id="foli11" class="leftHalf ">
<label class="desc" id="title6" for="Field11">
Telephone Number
<span id="req_11" class="req">*</span></label>
<div>
<input id="Field11" name="Field11" type="text" class="field text medium" value="" tabindex="5" required />
</div>
</li>
<li id="foli11" class="rightHalf ">
<label class="desc" id="title7" for="Field11">
Email
<span id="req_11" class="req">*</span></label>
<div>
<input id="Field11" name="Field11" type="email" spellcheck="false" class="field text medium" value="" maxlength="255" tabindex="6" required />
</div>
</li>
<li id="foli11" class="leftHalf ">
<label class="desc" id="title8" for="Field11">
Website
</label>
<div>
<input id="Field11" name="Field11" type="text" class="field text medium" value="" tabindex="5" required />
</div>
</li>
<li id="foli5" class="complex ">
<label class="desc" id="title9" for="Field5">
Address
<span id="req_5" class="req">*</span></label>
<div>
<span class="full addr1">
<input id="Field5" name="Field5" type="text" class="field text addr" value="" tabindex="7" required />
<label for="Field5">Street Address</label>
</span>
<span class="full addr2">
<input id="Field6" name="Field6" type="text" class="field text addr" value="" tabindex="8" />
<label for="Field6">Address Line 2</label>
</span>
<span class="left city">
<input id="Field7" name="Field7" type="text" class="field text addr" value="" tabindex="9" required />
<label for="Field7">City</label>
</span>
<span class="right state">
<input id="Field8" name="Field8" type="text" class="field text addr" value="" tabindex="10" required />
<label for="Field8">State / Province / Region</label>
</span>
<span class="left zip">
<input id="Field9" name="Field9" type="text" class="field text addr" value="" maxlength="15" tabindex="11" required />
<label for="Field9">Postal / Zip Code</label>
</span>
<span class="right country">
<select id="Field10" name="Field10" class="field select addr" tabindex="12" >
<option value=""></option>
<option value="United States" selected >United States</option>
</select>
<label for="Field10">Country</label>
</span></div>
</li>
<li id="foli15" class=" ">
<fieldset>
<![if !IE | (gte IE 8)]>
<legend id="title15" class="desc"></legend>
<![endif]>
<!--[if lt IE 8]>
<label id="title15" class="desc">
</label>
<![endif]-->
<div>
<div align="justify"><span>
<input name="Field15" type="checkbox" class="field checkbox" id="Field15" tabindex="13" value="This is a gift." checked />
</span></div>
<span><label class="choice" for="Field15">
<div align="justify">By checking this box, I agree that spelling, content and layout are correct. I understand that my document will print exactly as it appears above and that I cannot make any changes once my order has been placed. I understand this is an all sales final item. Please check the approval box to indicate that you approve this design and have read and agree this statement.</div>
</label>
</span></div>
</fieldset>
</li>
<li class="buttons ">
<div>
<div align="center">
<input id="saveForm" name="saveForm" class="btTxt submit" type="submit" value="Submit"
/>
<input id="saveForm" name="saveForm" class="btTxt submit" type="reset" value="Reset"
/>
</div>
</div>
</li>
</ul>
</form>
</div><!--container-->
<img id="bottom" src="images/bottom.png" alt="" />
</body>
</html>
My php coding:
[php]<?php
if(isset($_POST[‘email’])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "[email protected]";
$email_subject = "Business Card Information";
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['title3']) ||
!isset($_POST['title4']) ||
!isset($_POST['title5']) ||
!isset($_POST['title8']) ||
!isset($_POST['title9'])){
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$title3 = $_POST['title3']; // required
$title4 = $_POST['title4']; // required
$title5 = $_POST['title5']; // required
$title6 = $_POST['title6']; // not required
$title7 = $_POST['title7']; // not required
$title8 = $_POST['title8']; // required
$title9 = $_POST['title9']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$title3)) {
$error_message .= ‘The Email Address you entered does not appear to be valid.
’;
}
$string_exp = “/^[A-Za-z .’-]+$/”;
if(!preg_match($string_exp,$title6)) {
$error_message .= ‘The Name you entered does not appear to be valid.
’;
}
if(!preg_match($string_exp,$title9)) {
$error_message .= ‘The Address you entered does not appear to be valid.
’;
}
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 .= "Name: ".clean_string($title3)."\n";
$email_message .= "Rank: ".clean_string($title4)."\n";
$email_message .= "Telephone Number: ".clean_string($title5)."\n";
$email_message .= "Fax Number: ".clean_string($title6)."\n";
$email_message .= "Website: ".clean_string($title7)."\n";
$email_message .= "Email: ".clean_string($title8)."\n";
$email_message .= "Address: ".clean_string($title9)."\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);
?>
We’ve received your information. Thank you!
<?php } ?>[/php]