Hi guys,
I have been using the same contact form for all my sites but only recently noticed during tests (and from comments from one of my “clients”) that half of the time, emails dont go through.
I have just put this code in to my new site to test and the contact form processed fine, got me to my success page which then counted down and redirected me to the home page.
I did this twice and all seemed fine but I still havent had my test emails in my inbox.
This is the code I use:
HTML
[CODE]<form action=”processform.php” method=”post”>
<label for=”name”>Name</label><input type=”text” id=”name” name=”name” />
<label for=”email”>Email address</label><input type=”text” id=”email” name=”email” />
<label for=”topic”>Subject</label><input type=”text” id=”topic” name=”topic” />
<textarea id=”comments” name=”comments” rows=”5″ cols=”30″></textarea>
<button type=”submit” id=”sendmessage”>Send</button>
</form>
PHP file
[CODE]<?php
// Pick up the form data and assign it to variables
$name = $_POST[‘name’];
$email = $_POST[’email’];
$topic = $_POST[‘topic’];
$comments = $_POST[‘comments’];
// Build the email (replace the address in the $to section with your own)
$to = ‘my e-mail address’;
$subject = “New message: $topic”;
$message = “$name said: $comments”;
$headers = “From: $email”;
// Send the mail using PHPs mail() function
mail($to, $subject, $message, $headers);
// Redirect
header(“Location: success.html”);
And before you say it, I did have my e-mail address in the “to” bit, i’ve changed it for the purpose of this post. ?
Cheers, Adey