Page 1 of 1

How do I get the PHP to my Enquiry form to work?

Posted: Wed Feb 25, 2009 12:04 pm
by ched53
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.'; 
}
?>
 

Re: How do I get the PHP to my Enquiry form to work?

Posted: Wed Feb 25, 2009 4:09 pm
by Citizen
Are you receiving an error?

Also, use when posting php code on the boards.

Re: How do I get the PHP to my Enquiry form to work?

Posted: Thu Feb 26, 2009 2:40 am
by ched53
sorry, all I am getting simply a 'page not found'

This is all way over my head so I'd appreciate it if someone could shed some light on this. I posted exactly the same thing on my yahoo answers account and I've have so many responses but every single one is different, so its hard to know which one is right

Re: How do I get the PHP to my Enquiry form to work?

Posted: Thu Feb 26, 2009 5:18 am
by Paul Arnold
Cut and paste the following,

Code: Select all

<?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.';
}
?>
Into a php file called 'sendmail.php'.

Re: How do I get the PHP to my Enquiry form to work?

Posted: Thu Feb 26, 2009 5:59 am
by ched53
Well thats stopped me getting the 'page not found', its now doing what I asked and going back to the homepage when you click the submit button.

BUT I'm not receiving any emails :-(

So stressful. Please pardon my lack of knowledge on this topic