How do I get the PHP to my Enquiry form to work?
Posted: Wed Feb 25, 2009 12:04 pm
This has been such a nightmare. I am a complete newbie with PHP. I want the enquiry form (http://www.hairbykirbyblythe.co.uk/enquiries.h... to email the results to my clients account. I've followed all the information on the fasthosts helpdesk and still it doesn't work. Below is the code for my form and the PHP I added, can someone please tell me where I have gone wrong?
Code: Select all
<form method='post' action='sendmail.php'>
<label>Name:</label><p><input name="Name:" type="text" size="50" maxlength="50" /></p>
<label>Telephone Number:</label> <p><input name="telephone" type="text" size="50" maxlength="20" /></p>
<label>Email:</label><p><input name="email" type="text" size="50" maxlength="25" /></p>
<label>Enquiry:</label><p><textarea name="enquiry" cols="90" rows="12"></textarea></p>
<input type='submit' />
<input type="reset" />
</label></form>
<?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.';
}
?>