Saturday, January 26, 2008

How to install Ajax contact form

Dustin’s Ajax Contact Form is an unobtrusive (meaning, works even with JavaScript disabled) contact form done in PHP using which your site visitors can get in touch with you. It provides basic and most common form fields in a contact form.

Curent latest version: 0.9

Below are the instructions on how to set up on your site:

  1. Decide where you want the contact form to reside in your website structure. In this tutorial, we are going to install it at http://www.howtotuts.com/demos/ajaxcontactform/.
  2. Download the zip file from here and extract the contents to your local disk.
  3. Open scripts/contact.php in a text editor like notepad and edit the following four lines
    1. $yourName = 'John Doe';
    2. $yourEmail = 'user@example.com';
    3. $yourSubject = 'testJax';
    4. $referringPage = 'http://www.example.com/testJax/index.php';

    $yourSubject is the subject of the e-mail that you will be receiving when a visitor fills the form.
    $yourEmail is where you want the filled form data to be sent to.

    $referringPage is the URL of index.php of your contact form. In our example, it will be http://www.howtotuts.com/demos/ajaxcontactform/index.php

  4. Save the file and close it.
  5. Edit scripts/xmlHttpRequest.php similarly. Save and close the file.
  6. Edit index.php to remove/edit the text below the form.
  7. Using a FTP client, upload all the content of the contact form script (i.e., ‘img’, ‘js’, ’scripts’ folders and index.php) to the directory where you decided to install the form.

Done. Your visitors should now be able to contact you through your new shiny Ajax form. Here is our working form: http://www.howtotuts.com/demos/ajaxcontactform/

Note: This contact form script is not ideal (worth the effort to modify) if you want to include some custom fields (like a dropdown). For that, we’ll provide detailed coverage of another solution (the form that’s used on this site) soon.

No comments: