So below is the code I'm using for my page. This is all of the html/php on the page. For some reason it won't email out. I'm sure it will be something straight forward that I'm just not seeing... But as you know, the longer you stare at something the harder it is to find the error! So hopefully a fresh pair of eyes will be able to find it. Thanks in advance.
<?
session_start();
$your_email ='tom@targetedmanagement.com';// <<=== update to your email address
$errors = '';
$name = '';
$visitor_email = '';
$visitor_telno = '';
$user_message = '';
if(isset($_POST['submit']))
{
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$visitor_telno = $_POST['telno'];
$user_message = $_POST['message'];
///------------Do Validations-------------
if(empty($name)||empty($visitor_email))
{
$errors .= "\n Name and Email are required fields. ";
}
if(IsInjected($visitor_email))
{
$errors .= "\n Bad email value!";
}
if(empty($_SESSION['6_letters_code'] ) ||
strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0)
{
//Note: the captcha code is compared case insensitively.
//if you want case sensitive match, update the check above to
// strcmp()
$errors .= "\n The captcha code does not match!";
}
if(empty($errors))
{
//send the email
$to = $your_email;
$subject="eatabout contact form";
$from = "contact@eatabout.co.uk";
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
$body = "A user $name submitted the eatabout register interest form:\n".
"Name: $name\n".
"Email: $visitor_email \n".
"Telephone: $visitor_telno \n".
"Message: \n ".
"$user_message\n".
"IP: $ip\n";
$headers = "From: $from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
mail($to, $subject, $body,$headers);
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=thankyou.php">';
// header('Location: index.php');
}
}
// Function to validate against any email injection attempts
function IsInjected($str)
{
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str))
{
return true;
}
else
{
return false;
}
}
?>
<?
$eatabouttitle = "eatabout diners card, Blackpool's Number 1 Dining Card";
$titledescription = "eatabout diners card the newest and most exciting dining club experience in Blackpool";
$titlekeywords = "eatabout, eat about, eat-about, diners club, diners card, dining club, dining card, Blackpool restaurant, 2 4 1 dining, 2 for 1 dining, dining discount, restaurant discount, restaurant, restaurants, food dicount, eating discount";
require_once "header.php";
$locationid = 0;
?>
<link rel="stylesheet" type="text/css" href="css/form.css"/>
<div id ="home_content">
<div id="breadcrumb_holder">
<?
echo "<div class='breadcrumb'> Navigation:<a href='/' target='_parent' class='breadcrumb'>eatabout diners card homepage </a></div\n>";
?>
</div>
<script language="JavaScript" src="Scripts/gen_validatorv31.js" type="text/javascript"></script>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<img src="images/web banner 5.jpg" width="980" height="200"> </div>
<div id = "home_column_1">
<div class = "home_column_header1">
<div class = "home_style2"><span style="font-size: 20px"><strong></strong></span></div>
</div>
<div id="contactimagediv">
<div id="contactimagesdivright">
<img src="images/fillercontactimage.png" width="450" height="710" style="float:right"/>
</div>
<div class="container">
<div class="row header">
<h1>CONTACT US </h1>
<h3>One of our agents will contact you shortly!</h3>
</div>
<div class="row body" id="contact_form">
<div id='contact_form_errorloc' class='err'></div>
<form method="POST" name="contact_form" action=""<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"">
<ul>
<li>
<p class="left">
<label for="name">Name</label>
<input type="text" name="name" placeholder="John"
value='<?php echo htmlentities($name) ?>' />
</p>
<p class="pull-right">
<label for="number">Tel No.</label>
<input type="text" name="telno" width="300" placeholder="07---------"
value='<?php echo htmlentities($visitor_telno) ?>' />
</p>
</li>
<li>
<p>
<label for="email">Email <span class="req">*</span></label>
<input type="email" name="email" width="300" placeholder="john.smith@gmail.com"
value='<?php echo htmlentities($visitor_email) ?>' />
</p>
</li>
<li>
<div class="divider"></div>
</li>
<li>
<label for="comments">comments</label>
<textarea cols="46" rows="8" name="message"><?php echo htmlentities($user_message) ?></textarea>
</li>
<li>
<input class="btn btn-submit" type="submit" value="Submit" />
<small>or press <strong>enter</strong></small>
</li>
</ul>
</form>
<script language="JavaScript">
var frmvalidator = new Validator("contact_form");
//remove the following two lines if you like error message box popups
frmvalidator.EnableOnPageErrorDisplaySingleBox();
frmvalidator.EnableMsgsTogether();
frmvalidator.addValidation("name","req","Please provide your name");
frmvalidator.addValidation("email","req","Please provide your email");
frmvalidator.addValidation("email","email","Please enter a valid email address");
</script>
<script language='JavaScript' type='text/javascript'>
function refreshCaptcha()
{
var img = document.images['captchaimg'];
img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000;
}
</script>
<noscript>
</noscript>
</div>
</div>
</div>
<div id = "home_column_2">
<div class = "home_column_header2"></div>
</div>
<div class ="index_sub_header_container">
<div class ="index_sub_header"> </div>
</div>
<div class ="index_sub_content_container">
</div>
<!--Start of Tawk.to Script-->
<script type="text/javascript">
var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date();
(function(){
var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0];
s1.async=true;
s1.src='https://embed.tawk.to/560401a269653fe005f8b5a7/default';
s1.charset='UTF-8';
s1.setAttribute('crossorigin','*');
s0.parentNode.insertBefore(s1,s0);
})();
</script>
<!--End of Tawk.to Script-->
<?
require_once "footer.php";
?>
</div>
</body>