You are here: Home » All Posts » Contact Forms » Creating a contact form for your website

Creating a contact form for your website

in Contact Forms

Here is a ‘ready to use’ form that you can simply plug-in to your web site. All that you have to do is to download the code below, update the code to include your email, and attach form to your web site.
You can easily customize the form for your needs. The code is 100% validated XHTML1.0 strict.

Features of this contact form

  • Standards compliant, accessible form
  • 100% XHTML 1.0 strict validated, uses CSS2
  • Secured against spam and attacks
  • Validations done both on client side and on the server side
  • Uses PHPMail to send email
  • Easy to customize
  • Hosted on your own web server
  • Free!

Download the contact form code

You can download the contact form that best fits your needs and then customize as required.


Simple contact form with three fields: Name, Email and Message
Try the DemoDownload
Contact form with simple captcha
Contact form with Simple Captcha
Try the DemoDownload
contact form with image captcha
Contact form with fields: Name, Email, Phone and Message (and Image Captcha)
Try the DemoDownload

Installing the contact form on your web site

  1. Unzip the downloaded contact form code.
  2. Edit contactform.php and edit the email address to your email address
    $formproc->AddRecipient('name@your-website.com');//<<---Put your email address here
  3. Upload the folder contents to your website (to a sub-folder say, /contact)
  4. The contactform.php contains the form. You can link to this file or embed the form using iframe.

Sample iframe code to embed the form:

<iframe src='/contact/contactus.php' frameborder='0' width='100%' height='600' ></iframe>

Alternatively, you can modify contactform.php to have the same look of your web site.

Customizing the form

The contact form can be customized to match requirements. You can change the style, add more fields, and add more email recipients.

Changing the colors, fonts and style

You can edit the contact.css file to change the style of the form.

Adding more than one recipients

Call the AddRecipient() function passing the email address of the new recipient.Example:

 
$formproc->AddRecipient('name_1@your-website.com');
$formproc->AddRecipient('name_2@your-website.com');

Adding more fields

You can add any type of additional fields to the form. The fields will automatically be included in the form submission emails.

More Customizations …

For more features and customizations of the contact form, see the Related Pages section below.

License


The code is shared under LGPL license. You can freely use it on commercial or non-commercial websites.

Be Sociable, Share!
  • geoff

    found this form, looked just what I needed, followed instructions, uploaded, no form showing on site

  • George

    The simple captcha doesn’t work. It works on the demo but I downloaded files, uploaded to server, changed email address but each time I give the correct answer it says failed

  • http://www.moralintelligence.net/ Abdel Irada

    I note that there’s a rather high Q:A ratio in these comments.

  • Shal

    I copied all the folders and sub-directories as is, and changed the email address in contactform.php.
    The form comes up correctly. I enter valid data for all the fields and clicked submit. It comes back with the following error message:
    ‘Automated submission prevention: case 1 failed’
    Have not changed anything else

  • http://www.vankamurals.org/contactus1.html Mike

    The form looks fine and sends me to a Thank You page after I click Submit, but the data never reaches me. Any thoughts?

Previous post:

Next post: