Page 1 of 1

Fasthosts - Form to mail' script using PHP - HELP PLEASE!

Posted: Wed Nov 11, 2009 5:14 am
by ched_53
Firstly let me state I'm a complete NEWBIE when it comes to this, PHP is not my thing but i really need a contact form on my website.

The problem I have it that I have set up this very simple contact form but it just will not send to my fasthosts email address. I know the problem is some regarding the email because it worked perfectly find when I directed the mail to my yahoo email account.

I have posted the code i have used below. Please can someone help? I'm sure that the experienced PHP users out there will be able to help me. F.Y.I. I'm using a Linux fasthosts account.

Thanks so much in advance

contact.php:

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="50" /></p>
      <label>Enquiry:</label><p><textarea name="message" cols="90" rows="12"></textarea></p>
      <input type='submit' />
      <input type="reset" />
      </label></form>
<?php 
ini_set("sendmail_from", "aaron@ched53.co.uk"); 
mail($email_to, $email_subject, $email_message, $headers, "-faaron@ched53.co.uk"); 
?>
 
sendmail.php

Code: Select all

 
<?php
error_reporting(E_ALL ^ E_NOTICE);
$email_to      = "aaron@ched53.co.uk";
$name          = $_POST['name'];
$email_from    = $_POST['email'];
$email         = $_POST['email'];
$comments      = $_POST['message'];
$telephone     = $_POST['telephone'];
$email_subject = "Enquiry";
$headers       = "From: $email_from\r\nReply-To: $email_from\r\n";
$message       = "Name: "        .$name 
                 ."\ntelephone: ".$telephone
                 ."\nemail: "    .$email
                 ."\nenquiry: "  .$comments;
 
$sent = mail($email_to, $email_subject, $message, $headers);
if ($sent) {
  header( "Location: http://www.ched53.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.';
}
?>