Here is the code, copy and save to a file:
(Tutorial Follows) Anything in red can, or will need to be changed
<?php if($_POST['submit']){ $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; if (!$name) die(‘Sending Failed, please fill in all fields.’); if (!$email) die(‘Sending Failed, please fill in all fields.’); if (!$message) die(‘Sending Failed, please fill in all fields.’); $ToName = “Mat”; $ToEmail = “*********@bakerdesigns.co.uk”; $FromName = “$email”; $Subject = “New Question”; $Message = $message.”\n\nFrom: “.$name; $headers = “From: “.$FromName.”"; mail($ToEmail, $Subject, $Message, $headers)or die(“Email could not be sent”); die(‘ <html> <head><meta http-equiv=”refresh” content=”6;URL=\’../index.html\’”></head>
<body><div align=”center” style=”margin-top:200px; color:#333333;”><h2>Your Message Has Been Sent</h2><p>Thank you for your message, a reply will be sent shortly</p><p>You will shortly be redirected back to the homepage automatically</p><p><img src=”../images/ajax-loader.gif” alt=”Redirecting” /></p></div></body> </html> ‘);
}
?>
The Tutorial
First you need to create a HTML form. It needs to have three fields, one named name, one named email and another named message. Add a submit button. Make sure your HTML form’s action is set to the PHP file which contains the code above. Here is my example code:
<form id=”form1″ name=”form1″ method=”post” action=”scripts/FormToEmail.php“> Full Name:<input type=”text” name=”name” id=”name” /> Email Address:<input type=”text” name=”email” id=”email” /> Message:<textarea name=”message” id=”message” cols=”35″ rows=”5″ onmousemove=”FillForm()”></textarea> <input type=”submit” name=”submit” id=”submit” value=”Submit” /> </form>Now change everything in red such as the redirect in the code and the ‘action’ tag in the HTML form. Also, you will need to copy the animated GIF below and save it somewhere. Put the location of this file in the PHP code section where the file location of “ajax-loader.gif” is placed.








