Hi Guys,
I’m having a problem on my PhP mail form which I’ve found from somewhere else. The problem is when I sent the details filled, it says all right and was sent successfully… however, I don’t recieve any mail.
There are plenty of people also confronted with the same problem and one of the reasons that could occur the failure might be server side they say… I’ll speak to my hosting if it is about the post-mail script but in the meantime I’d like have an opinion by the professionals in order to save time.
If you please check the code below that would be really grateful;
[php]<?php
$myemail = "[email protected]";
$fname = check_input($_POST[‘fname’], “Enter your name”);
$sname = check_input($_POST[‘sname’], “Enter your surname”);
$address = check_input($_POST[‘address’], “Enter your address”);
$postcode = check_input($_POST[‘postcode’], “Enter your postcode”);
$phone = check_input($_POST[‘phone’]);
$mail = check_input($_POST[‘mail’]);
$totaldebtamount = check_input($_POST[‘totaldebtamount’], “Please select a total debt amount”);
$totalcreditors = check_input($_POST[‘totalcreditors’], “Please select a total creditor”);
$employmentstatus = check_input($_POST[‘employmentstatus’], “Please select an employment status”);
$whatworries = check_input($_POST[‘whatworries’], "Please select a detail from What worries you most about your finances?
");
$preferredmethod = check_input($_POST[‘preferredmethod’], “Please select a method in order to contact with you”);
if (!preg_match("/^[0-9. ]+$/", $phone))
{
show_error(“Phone number is wrong”);
}
if (!preg_match("/([\w-]+@[\w-]+.[\w-]+)/", $mail))
{
show_error(“E-mail address not valid”);
}
$message = "Hello!
Your contact form has been submitted by:
Name: $fname Surname: $sname
Address: $address Post Code: $postcode
Phone: $phone E-mail: $mail
Total Debt Amount: $totaldebtamount
Total Creditors: $totalcreditors
Employment Status: $employmentstatus
Preferred method of contact: $preferredmethod
End of message
";
mail($myemail, $subject, $message);
header(‘Location: thanks.htm’);
exit();
function check_input($data, $problem=’’)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<span class="gBtitleW"><b>Please correct the following error:</b></span><span class="gForm1"><em><br>
<br/>
<?php echo $myError; ?>
</em></span><br>
<br>
<span class="gForm1"><a href="javascript:history.go(-1)" class="gBtitleW">< Back</a></span>
</body>
</html>
<?php
exit();
}
?>[/php]