I was wondering if anyone has come across this problem and knows why my form is not sending emails only in Chrome and Safari. I am new to php so any advice and help is much appreciated. Thanks in advance.
settings.php file below:
<?php
$email_to = "myemail@yahoo.com"; // your email address
$email_subject = "Contact Form Message"; // email subject line
$thankyou = "index.html"; // thank you page
?>
process.php file below:
<?php
if(isset($_POST['Email_Address'])) {
include 'settings.php';
if($email_to == "youremailaddress@yourdomain.com") {
die("This message is for the Webmaster. Please enter your email address into the file 'settings.php'");
}
function died($error) {
echo "Sorry, but there were error(s) found with the form your submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
if(!isset($_POST['Full_Name']) ||
!isset($_POST['Email_Address']) ||
!isset($_POST['Telephone_Number']) ||
!isset($_POST['Your_Message'])) {
died('We are sorry, but there appears to be a problem with the form your submitted.');
}
$full_name = $_POST['Full_Name']; // required
$email_from = $_POST['Email_Address']; // not required
$telephone = $_POST['Telephone_Number']; // required
$comments = $_POST['Your_Message']; // required
$error_message = "";
$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$";
if(strlen($full_name) < 2) {
$error_message .= 'Your Name does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($telephone) < 2) {
$error_message .= 'The number you entered does not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\\r\
";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Full Name: ".clean_string($full_name)."\\r\
";
$email_message .= "Telephone: ".clean_string($telephone)."\\r\
";
$email_message .= "Email: ".clean_string($email_from)."\\r\
";
$email_message .= "Message: ".clean_string($comments)."\\r\
";
$headers = 'From: '.$email_from."\\r\
".
'Reply-To: '.$email_from."\\r\
" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
header("Location: $thankyou");
?>
<script>location.replace('<?php echo $thankyou;?>')</script>
<?
}
?>
<form id="form" action="process.php" method="post">
<table class="table_form">
<tr>
<td class="c1">
<div class="div_input">Name:<b style="color:#d90e86;"> *</b><span id="sprytextfield1">
<input id="Full_Name" name="Full_Name" type="text" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldMinCharsMsg">Minimum number of characters not met.</span></span></div>
<div class="div_input">E-mail:<input id="Email_Address" name="Email_Address" type="text" /></div>
<div class="div_input">Phone:<b style="color:#d90e86;">*</b><span id="sprytextfield2">
<input id="Telephone_Number" name="Telephone_Number" type="text" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldMinCharsMsg">Minimum not met.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></div>
</td>
<td class="c2">Message:<b style="color:#d90e86;">*</b>
<span id="sprytextarea1">
<textarea name="Your_Message" cols="0" rows="0"></textarea>
<span class="textareaRequiredMsg">A value is required.</span><span class="textareaMinCharsMsg">Minimum number of characters not met.</span></span></td>
</tr>
</table>
<div>
<input class="sendbttn" name="submit" type="submit" value="Send" /></div>
</form>