I'm having an absoloute nightmare trying to get an enquiry form to work on a website that I am designing. Firstly, let me point out I am a complete newbie with PHP so please pardon my ignorance on the subject, im a graphic designer not a programmer. The address for the page where the enquiry form is http://www.hairbykirbyblythe.co.uk/enquiries.html.
So far I am at a point where clicking the submit button correctly goes to the 'Thanks for your message' page, but no email is being received at all. Can someone please tell me what is wrong with my code?
This is the php on the enquiries page itself:
<?php
ini_set("sendmail_from", " kirby@hairbykirbyblythe.co.uk ");
mail($email_to, $email_subject, $email_message, $headers, '-fkirby@hairbykiryblythe.co.uk');
?>
<?php
ini_set('sendmail_from', $email_from);
$email_to = "kirby@hairbykirbyblythe.co.uk";
$name =$_POST['Name'];
$email_from =$_POST['email'];
$email_subject = "Enquiry";
$comments = $_POST['message'];
$headers =
"From: $email_from .\n";
"Reply-To: $email_from .\n";
$message= "Name: ". $name . "\ntelephone: " . $telephone; "\nemail: " . $email;
$sent = mail($email_to, $email_subject, $message, $headers, '-f .$email_from');
if ($sent)
{
header( "Location: http://www.hairbykirbyblythe.co.uk" );
} else {
/* If there is an error display an error message */
echo 'There has been an error sending your enquiry. Please try later.';
}
?>
And my sendmail.php file is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
ini_set("sendmail_from", " [email]kirby@hairbykirbyblythe.co.uk[/email] ");
mail($email_to, $email_subject, $email_message, $headers, '-fkirby@hairbykiryblythe.co.uk');
?>
<?php
ini_set('sendmail_from', $email_from);
$email_to = "kirby@hairbykirbyblythe.co.uk";
$name =$_POST['Name'];
$email_from =$_POST['email'];
$email_subject = "Enquiry";
$comments = $_POST['message'];
$headers =
"From: $email_from .\n";
"Reply-To: $email_from .\n";
$message= "Name: ". $name . "\ntelephone: " . $telephone; "\nemail: " . $email;
$sent = mail($email_to, $email_subject, $message, $headers, '-f .$email_from');
if ($sent)
{
header( "Location: http://www.hairbykirbyblythe.co.uk/thanks.html" );
} else {
/* If there is an error display an error message */
echo 'There has been an error sending your enquiry. Please try later.';
}
?>
</body>
</html>
The host of the account is Fasthosts on a Windows home package if this helps. All help and advice would be much appreciated. I've had this issue for months now and just want to get it sorted 🙁