You are here: Home » All Posts » Contact Forms » Here is a simple popup contact form (modal popup)

Here is a simple popup contact form (modal popup)

in Contact Forms

A popup contact form has many benefits. You can add a button/link in every page that pops up the contact form in a modal popup. That makes the contact form easily accessible from any part of the website.

Your web site visitors do not have to 'hunt' for the 'contact us' page.

Download the popup contact form code

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

Simple popup contact form
Simple popup contact form with three fields: Name, Email and Message
Try the DemoDownload
Popup form with Captcha
Popup contact form with Captcha image verification
Try the DemoDownload

Features of the popup contact form

  • Easy to customize
  • Standards compliant (100% XHTML 1.0 strict validated, uses CSS)
  • Secured against spam bots and attacks
  • Ajax submission.
  • Hosted on your own web server
  • Free!

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
  3. $formproc->AddRecipient('name@your-website.com');//<<---Put your email address here
    
  4. Upload the folder contents to your website (to a sub-folder say, /contact)
  5. See the page a-page.php for an example of integrating a button/link to the popup contact form.
  6. Include the file popup-contactform.php at the beginning of your php file
  7. link to the style file popup-contact.css in the <head> section of your page
  8. PHP include contactform-code.php at the end of your php file (it should come in between <body> and </body>)
  9. To Open the Popup form on clicking a link, use the code below:
  10. <a href='javascript:fg_popup_form("fg_formContainer","fg_backgroundpopup");'>Contact us</a>
    

Customizing the form

To change the style of the form, edit popup-contact.css.

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

For client side validations, this script uses the JavaScript validation library. You can add additional client side validations using the same library. (See the documentation here: JavaScript form validation library).

Additional server side validations can be added in the file 'include/fgcontactform.php' Validate() function.

License


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

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay

Related posts:

  1. A simple, easy PHP contact form

{ 89 comments }

Stuart Dutton June 13, 2011 at 8:01 pm

Hi..
 
I am wondering if there is a way or a function to pass name and email data from form to the thank you page..  ?  I am quite new to this and would appreciate any guidance you could provide.  Also the modal box seems to retain the thank you page once its finished unless you refresh the page..  The page I am working on may get multiple contact forms filled out during a session and was wondering if there was a way of resetting the form away from the thank you page ready for the next input..
 
Thanks in advance.
 
Best Regards
 
Stuart :)

kurniawan July 3, 2011 at 1:32 pm

Thank you. just added to my website. easy to use.

sydney July 7, 2011 at 11:36 am

How do i implement your form using smtp server  with authentication  to send mail
 
Regards

Kedar H July 14, 2011 at 6:19 am

Thank you very much. It is very nice and easy to implement. Great… :)

Jako March 16, 2012 at 10:46 am

Hi,
Since you have had ‘better luck’ with this script, I wonder if you could kindly assist with my own rendering please? When I click on the link, nothing happens.

Mark July 18, 2011 at 8:06 am

It is very good tool.
Thanks for your help.

Donna July 20, 2011 at 2:00 pm

I am having the same error “Automated submission prevention: case 1 failed”. I don’t see a solution posted for the cause. What am I doing wrong?
Thanks

Zang July 25, 2011 at 1:34 pm

hi,
This is absolutely wonderful,  just want to say thank you very much, solved my problem, very stylish and secure too!! good job

satish G August 3, 2011 at 1:28 pm

Hello, I like this script very much, really its best of the best contact forms with full variety. I would like to integrate it on my site but no luck everything is fine captcha also works fine but i cant received email from my newly registered domain (website) contact form.

raj August 5, 2011 at 2:06 pm

My host says only through SMTP  with authentication  to send mail. Can someone please tell where i can get a simple download and paste scrip for SMTP mail servers ?

Marie_Phil August 19, 2011 at 7:28 pm

Thanks for this script. You save my problem.
 

Jason August 24, 2011 at 1:27 am

Hi, I can’t include php file on my html files, is there any other way to use this form on html files.
(I can’t change html to php or use htaccess , my file should stay html)
Thanks for any help.

Financial Advisor November 16, 2011 at 10:39 am

great article, put it on my website, check it out.

ModalFormer November 19, 2011 at 10:49 pm

I like the design and programming of your modal form, however like some others here the form wouldn’t send. After submitting, nothing happens – not even an error code appears. I suspect could be due to my host which is GoDaddy.com. The most basic mail() command works there, but nothing else.
Unfortunately I have run out of ideas on how to still use the original code. I am currently replacing the lines in SendFormSubmission() within fgcontactform. Seems the only viable option for now for me.
Do you have any suggestions for me? Many thx in advance!

ModalFormer November 20, 2011 at 12:46 am

Also, I noted a small error in the contactform-code.php: the line
var formobj = document.forms['contactus']
is missing a ; at the end. So the correct line should read:
var formobj = document.forms['contactus'];
in order to make the script work I believe…

Amit Kondewar November 22, 2011 at 4:53 am

Thanks for valuable example

r t November 23, 2011 at 1:54 pm

Hi, how to insert the data into the database

idris November 27, 2011 at 6:04 pm

this is exactly what i was looking for…thank you for sharing!!!

sebastian November 28, 2011 at 12:41 pm

hi there,

thanks for the tutorial, i have a little problem – the popup does not open but i have followed all steps exactly :)

any clues?

Vibhuti Ranjan December 3, 2011 at 10:31 am

very helpful this code.and easy way to use

Thanks .

Jako March 16, 2012 at 11:03 am

As you have found the code easy to use, Vibhuti, perhaps you wouldn’t mind showing the changes YOU had to make to the scripts and where exactly you made those changes. You would be saving the life of a novice. Thanks, pal.

ali December 10, 2011 at 11:34 am

please i want your help just i want popup code with out contact form can you please help me because this for my college project

Comments on this entry are closed.

Previous post:

Next post: