Email form
Posted: Wed May 21, 2008 4:54 am
This will probably seem like an extremely simple request, but I'm a relative newbie when it comes to PHP. I'm looking to create a contact form that will email the information to a central email address. I've implemented one before, but for some reason - the new one I'm working on doesn't seem to work at all. Even though all I've done is modified the code. I can't seem to figure it out. Any help would be appreciated. Firstly, here's the code for the form\;
And the PHP code:
Any ideas where I'm going wrong? PHP is enabled on the server, and as I've said the code has worked before on other projects I've used it with. It's probably not the best method, but my knowledge of PHP is extremely limited.
Thanks very much,
Chris
Code: Select all
<form name="form" method="post" action="email.php">
<label class="label" for="name">name:</label>
<input name="name" class="inputbox" id="name" type="text">
<br />
<label class="label" for="address">address:</label>
<textarea name="address" rows="1" wrap="virtual" class="inputbox" id="address"></textarea>
<br />
<label class="label" for="postcode">postcode:</label>
<input name="postcode" class="inputbox" id="postcode" type="text">
<br />
<label class="label" for="postcode">telephone:</label>
<input name="telnumber" class="inputbox" id="telnumber" type="text">
<br />
<label class="label" for="email">email:</label>
<input name="email" class="inputbox" id="email" type="text">
<br />
<label class="label" for="enquiry">enquiry:</label>
<textarea name="enquiry" class="inputbox" id="enquiry" type="text"></textarea>
<br />
<label class="long" for="product">please tick if you would like a product CD:</label>
<input name="product" id="checkbox" type="checkbox" value="yes" >
<br />
<input name="submit" type="submit" value="Submit" onClick="return validate(form)" class="button" id="submit" />
<br />
</form>Code: Select all
<?php
$redirect = "http://www.weirs.co.uk/thanks.html";
$sendTo = "chris@themarketingcafe.net";
$subject = "Weirs Web Enquiry";
$headers = "From: " . $_POST["name"];
$headers .= "<" . $_POST["email"] . ">\r\n";
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
$headers .= "Return-Path: " . $_POST["email"];
$message = "Name: " . $_POST["name"] . "\n\n";
$message .= "Address: " . $_POST["address"] . "\n";
$message .= "Postcode: " . $_POST["postcode"] . "\n";
$message .= "Telephone number: " . $_POST["telnumber"] . "\n";
$message .= "Email address: " . $_POST["email"] . "\n";
$message .= "Request product CD: " . $_POST["product"] . "\n\n";
$message .= "Enquiry: " . $_POST["enquiry"];
mail($sendTo, $subject, $message, $headers);
header("Location:$redirect");
?>Thanks very much,
Chris