A contact form is likely one of the most basic elements every website has and needs. If you do not have one or do not know how to use the one you have this simple contact form is just what you need. I won’t go into too much detail for the code itself, but will post the demo, download link, and explain what you need to edit in each file.
Demo url: http://www.focusedtutorials.com/contact-form/
Download link: http://www.focusedtutorials.com/downloads/contact.zip
The following is how you customize this form for yourself.
First you have to edit the $to variable otherwise the emails will come to us and not to you. Look in the process.php file for the following (lines 38 & 39):
// This is who it is To
$to .= 'spam@focusedtutorials.com'; // EDIT HERE
Update the email address you see there with the email address you want the form to send to. [Make sure it still has the ‘ on each side. (DO NOT REPLACE with quote marks)]
Secondly, you have to edit the $subject variable. This will allow incoming emails to the address you just edited to be identified as something from this contact form. Locate in the process.php file the following (lines 41 & 42):
// This is the Subject
$subject = 'Website Contact'; // EDIT HERE
Change Website Contact to whatever you want your subject to be. [Make sure it still has the ‘ on each side. (DO NOT REPLACE with quote marks)]
Thirdly, you have to edit the $url variable. This tells the form to load a certain page after sending the email. Locate in the process.php file the following (lines 67 & 68):
//Set this as the page to goto after emailing
$url = 'http://www.focusedtutorials.com'; // EDIT HERE
Change the url you see there to any page you wish loaded. Could be a thank you page, could be a special advertising page, could be anything you want. [Make sure it still has the ‘ on each side. (DO NOT REPLACE with quote marks)]
Lastly, you only need to customize the index.php page to include your code. Just make sure you place your code around the existing code so that you do not inadvertantly delete something of importance.
If you are looking to add a bit of flashy-ness to your site I would suggest looking into an AJAX contact form by Dustin Diaz’s. It is a simple one like this, only it involves Javascript. Quite cool as it processes instantly before your eyes and even has a processing image.
special thanks to: TJ Singleton for creating the template from which I modified to fit what we needed.
June 5th, 2006 at 10:11 pm
[…] Simple Contact Form: […]
June 6th, 2006 at 10:49 pm
:) Thanks for the mention!
July 24th, 2006 at 7:06 pm
[…] Re: Comment form jonbenitos, Here this may help: Simple Contact Form __________________ visit my sites: Unique Web Design and Development | Focused Tutorials | Focus Minded | What’s Your Factor? […]
January 2nd, 2007 at 11:18 pm
White this is an awesome form, and I have used it for quite a while, today a spammer figured out how to use/utilize it as well, so now I am digging in and having to figure out how to secure it. Spammers….
January 3rd, 2007 at 9:37 am
@Deron: Sorry to here that. I’ve been meaning to refactor the code for just that reason. I’ll get a new version release asap.
January 3rd, 2007 at 9:45 am
Actually TJ, somehow I got on your form site and I thought I was commenting about the Ajax form by Dustin Diaz (that’s the one I was referencing about the spam attack). Sorry about that! I’ll give yours a spin.
May 3rd, 2007 at 1:53 pm
First of all thank you for the form, it is really easy to get it work.
But i have have one problem. If I tried to send the form without filling out the fields, or donĀ“t fill out a required field. I end up on a blank page. I guess the form is missing a code for “if the fields are not correct filed out go to this page”. I would be glad if you can inform me how to fix that.
Thankfully
Mathias