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.


  • 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 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 = ““;

ii) Replace with the website address where the form is located.

$referers = array (‘‘);

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.

Here’s the sample code of the form above that collects the name and email address of your website visitors. Replace with your own website address.

<title>Contact Us</title>
<body bgcolor="#FFFFFF" text="#000000">
<form name="Contact Us" method="post" action="">
<input type=hidden name="subject" value="Contact Us Form Results">
<input type=hidden name="required" value="fullname,email">
<input type=hidden name="redirect" value="">
Full Name<br>
<input type=text name="fullname">
Email Address<br>
<input type=text name="email">
<textarea name="comments"></textarea>
<input type="submit" name="Submit" value="Submit">

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.

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.

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
Web Design, SEO, Article Marketing