I maybe out of date on this, so feel free to tell me so! Just gone back to an old form, replicated it for a standard site, no back end database or CMS system.
Form looks like this:
<form action="contact-form-handler.php" method="post">
<div>
<label for="name">Name:</label>
<input type="text" name="name" id="name" />
</div>
<div>
<label for="email">E-mail:</label>
<input type="email" name="email" id="mail" />
</div>
<div>
<label for="number">Telephone:</label>
<input type="number" name="number" id="number" />
</div>
<div>
<label for="message">Message:</label>
<textarea id="message" name="message" id="message"></textarea>
</div>
<div class="button">
<button type="submit">Send your enquiry</button>
</div>
</form>
The PHP looks like this:
<?php $errors = '';$myemail = '**removed**';//<-----Put Your email address here.
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['message']))
{
$errors .= "\n Error: all fields are required";
}
$name = $_POST['name'];
$number = $_POST['number'];
$email_address = $_POST['email'];
$message = $_POST['message'];
if (!preg_match("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$^",$email_address))
{
$errors .= "\n Error: Invalid email address";
}
if( empty($errors))
{
$to = $myemail;
$email_subject = "Quotation form submission: $name";
$email_body = "You have received a new message from your website".
"Here are the details:
\n Name: $name
\n Telephone Number: $number
\n Email: $email_address
\n More Info: \n $message";
$headers = "From: $myemail";
mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header('Location: thank-you.html');
}
?>
Now when I've uploaded, it looks like it works, but nothing gets emailed. Obviously there is a correct email address in the PHP at the top, I've just removed it for the innocence sake!
Any ideas? Am I too out of date for this to do what it used to? It's currently here: http://www.fatherof4.co.uk/rb/contact.html
Thanks in advance :)