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
    $yourName = 'John Doe';
    $yourEmail = 'user@example.com';
    $yourSubject = 'testJax';
    $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.

We hope you found this how-to helpful. Please social bookmark this tutorial and help us and others. Thanks in advance.

This post has 2 comments.

  1. Hi,

    This looks like a great little tool. I uploaded the script on my website and it works great, however I am not getting any emails arriving to my email address.

    What might be the problem? I thought first that it might be my server, but they say that they support PHP fine. What could be the reason? On the website the form works fine, but no emails. I have changed the email address in the script, is there something else I should do?

    Thanks

  2. koi
    18 Aug 08
    6:06 am

    yey! thx for the tutorial! I really didn’t have an idea how the contact form works, but now I’ve got a working contact form which I have the freedom to stylize thank you very much! :D

Close
E-mail It