How to Create a Contact Us Form for Your Website – 7 steps
Have you ever wanted to ask a question from a website and discovered there was no way to contact the site owner?
They didn’ t have an email address or contact us form on any of their web pages. This would prevent visitors from doing business with this website because it gives the impression they have something to hide and therefore cannot be trusted.
A live (hyperlinked) email address placed on a website can easily be spammed or harvested by spammers. Creating a contact us form is the best solution.
How to Create a Contact Us Form for Your Website
We’ll be using a free PHP script that can quickly and easily be added to any of your webs pages to collect information from your visitors.
Requirements
- Linux server with PHP4 or higher installed (most popular servers have this already)
- PHP script
- HTML page (where your contact us form is located)
- Thankyou page (to confirm subscriptions)
1. Get the script code
Go to http://www.ihost-websites.com/contactuscode.txt to get the code for the script. Copy and paste (select all) the entire code into Notepad (o text editor) and save it as securemail.php
2. Edit the script
i) Replace this line with the email address or addresses you wish to use to receive the results of the form.
$recipient = “you@yourdomainname.com“;
ii) Replace yourdomainname.com with the website address where the form is located.
$referers = array (‘yourdomainname.com‘);
3. Create an HTML web page and insert the form code
Create a web page (e.g. contact.htm) that contains the html form code.
e.g. http://www.ihost-websites.com/contact.htm
Here’s the sample code of the form above that collects the name and email address of your website visitors. Replace yourdomainname.com with your own website address.
<html>
<head>
<title>Contact Us</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="Contact Us" method="post" action="http://www.yourdomainname.com/securemail.php">
<input type=hidden name="subject" value="Contact Us Form Results">
<input type=hidden name="required" value="fullname,email">
<input type=hidden name="redirect" value="http://www.yourdomainname.com/thankyou.htm">
Full Name<br>
<input type=text name="fullname">
<br>
Email Address<br>
<input type=text name="email">
<br>
<br>
Comments
<br>
<textarea name="comments"></textarea>
<br>
<br>
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
Explanation of code
- method=post action refers to the form location on the server.
- hidden name=”subject” value refers to the name of your form and how it will appear in the form results
- hidden name=”required refers to the fields required to be filled out on the form. If they don’t get filled out the form will cannot be submitted.
- Remove this line of code if you don’t want required fields.
- hidden name=”redirect” refers to the page visitors get redirected to after submitting the form.
4. Create a thankyou.htm page
Your visitor will receive this page after submitting the contact us form.
e.g. http://www.ihost-websites.com/thankyou.htm
Write something like “Thank you for subscribing!” to confirm your visitor successfully subscribed.
5. Add additional form fields
You don’t have to be limited to name and email address. Other form fields can easily be added to the form (e.g. phone number, address, etc)
6. Upload files to the server
Upload securemail.php, contact.htm, thankyou.htm to the server using your FTP software (e.g. Filezilla, SmartFTP).
7. Test your contact us form
Go to the web page containing your contact us form, enter your name and email address, then click on the submit button. You should immediately receive the thankyou.htm page. Check your email inbox to view the contact form results. If you receive any errors check the script edits, html in your form and that you’ve uploaded your files correctly.
Tip
Place a contact form on every web page because visitors may enter your website from any page. Create an incentive for visitors to subscribe by offering an free report. This will help build your email subscriber list.
And now I would like to invite you to claim your FREE report titled:
7 Habits of Highly Effective Traffic Generation
Herman Drost is the owner and author of
http://www.DrostDesigns.com
Web Design, SEO, Article Marketing

February 22nd, 2010 at 6:16 am
nice post. good luck with the blog and keep up the good content coming.
February 22nd, 2010 at 10:22 am
Thanks for your words of encouragement!
February 28th, 2010 at 10:50 am
Superb Blog, you have a new follower now
March 2nd, 2010 at 4:36 am
Lots of Fantastic information in your blogpost, I favorited your blog so I can visit again in the future, All the Best, Rubie Hogains
March 4th, 2010 at 1:49 am
I imagine it is. Very good stuff, glad I found this.
March 6th, 2010 at 9:11 am
Thank you for this nice post.
March 6th, 2010 at 3:13 pm
Thanks for the info.
March 6th, 2010 at 3:14 pm
Thanks for the info.
March 7th, 2010 at 12:00 pm
I tried to subscribe to your rss, but had a difficulty adding it to google reader. Could you please check this out.
March 8th, 2010 at 9:14 am
Success in any business will not happen overnight. It still takes time and work to get your affiliate marketing strategy up and running. Nevertheless, if you are determined, decided and ready to give it your all, affiliate marketing can be the perfect career chance for you.
March 11th, 2010 at 1:05 am
Ive been reading along for a while now. I just wanted to drop you a comment to say keep up the good work.
March 11th, 2010 at 8:02 am
I’m agree with you, here we learn about very well features. I should just give up and take lessons from you
March 11th, 2010 at 11:50 pm
Great information! I’ve been looking for something like this for a while now. Thanks! Roberto Justus
March 16th, 2010 at 5:29 pm
Thanks for taking the time to share this with us, just loved it.
April 28th, 2010 at 2:29 pm
can i bookmark this site for future reference? i really like this info that you give
April 29th, 2010 at 11:33 am
Yes please Damien…go ahead.
June 15th, 2010 at 9:14 pm
Hi, Whats up? Thanks for this good stuff. I am looking for some help from your articles as I learn how to earn extra money at home.
June 17th, 2010 at 11:38 am
I’ve heard of this before, but is it worth the price?
July 30th, 2010 at 6:46 am
[...] If you’re using an autoresponder service such as Aweber they’ll provide the html code to insert on your web page. If you wish to create your own form go to: How to Create a Contact Us Form for Your Website [...]
December 27th, 2010 at 5:10 am
Hi, I am glad to find so many useful info here, this is a really great website. Thanks a lot for this amazing good posts! I will bookmark your site and take the feeds also… I hope you will keep updating your posts constantly as you have one dedicated reader here.
January 12th, 2011 at 3:40 am
I do not really have a good deal to say in reply, I only this minute want to comment to say great job. It looks like you’ve put a good amount of effort into your post and we require much more of these on the net nowadays.
January 18th, 2011 at 3:00 pm
I am very thankful to this topic because it really gives great information ;*”