Free PHP Contact Form
Thanks to the wonders of PHP and it’s built in sendmail function its never been easier to code a basic contact form. Follow the instructions below to create a basic contact form or at the bottom of the page there is a direct download link if you want it ready made.
Step 1: Using Notepad create a new page and save it as “contact.php”.
Step 2: Copy and paste the following code:
<?php //////Free Contact Form by Hampshire Web Design: http://www.hants-web.co.uk/
if ($_POST["email"]<>”) {
$ToEmail = ‘youremail@yourdomain.com’;
$EmailSubject = ‘Site contact form ‘;
$mailheader = “From: “.$_POST["email"].”\r\n”;
$mailheader .= “Reply-To: “.$_POST["email"].”\r\n”;
$mailheader .= “Content-type: text/html; charset=iso-8859-1\r\n”;
$MESSAGE_BODY = “Name: “.$_POST["name"].”<br>”;
$MESSAGE_BODY .= “Email: “.$_POST["email"].”<br>”;
$MESSAGE_BODY .= “Comment: “.nl2br($_POST["comment"]).”<br>”;
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die (“Failure”);
?>
<p align=”center”>Your message has been sent and we will respond within 24 hours.</p>
<?php
} else {
?>
<form action=”contact.php” method=”post”>
<table align=”center” width=”600″ border=”0″ cellspacing=”2″ cellpadding=”0″>
<tr>
<td width=”29%” align=”left” valign=”top”><strong>Your name:</strong></td>
<td width=”71%”><input name=”name” type=”text” id=”name” size=”80″></td>
</tr>
<tr>
<td align=”left” valign=”top”><strong>Email address:</strong></td>
<td><input name=”email” type=”text” id=”email” size=”80″></td>
</tr>
<tr>
<td align=”left” valign=”top”><strong>Comment:</strong></td>
<td><textarea name=”comment” cols=”61″ rows=”6″ id=”comment”></textarea></td>
</tr>
<tr>
<td> </td>
<td align=”left” valign=”top”><input type=”submit” name=”Submit” value=”Send”></td>
</tr>
</table>
</form>
<?php
};
?>
Step 3: Change the Email Address on line 3 “$ToEmail = ‘youremail@yourdomain.com’; ” to the email address you want the form contents to be sent to.
Step 4: Save your work and upload contact.php to your server and browse to www.yourdomain.com/contact.php and you should see the image below:

Thats it!
If you want it ready made then you can download the file from HERE.
Now im very sorry but we are too busy to answer customisation questions. If you would like to create a more advanced contact form then i would recommend reading some of the free tutorials at http://www.w3schools.com/.
This entry was posted on Monday, August 9th, 2010 at 11:40 pm and is filed under Free Downloads. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.


