Home - Help & Support - Contact Us
    

Free PHP Contact Form Script Documentation

Introduction:

Every web site needs a way to communicate with users! A contact-Us form is expected to be on every web site. Zeronese.net is proud to present this complex high end free contact form script to its visitors. This contact form is a member of the webmaster tools family, it takes into account new comers. In this regards, if you find some simple information in this documentation, you have to remember when you were a novice and think about the many who are making their first step to having a web site or regular users who do not need to learn any technicalities but still need to use a contact form!

Features:

Being free does not mean that the form has to be cheap! This zeronese php contact form script is a very complex powerful php script. Zeronese.net has took all measures to make the form useful and easily customizable. This is a list of the contact form features:

1- Supports most of contact forms required fields. List of fields and options that that you can easily change from the settings file:

  • Title (Options: show/hide, minimum characters required, label text)
  • First Name (Options: show/hide, minimum characters required, label text)
  • Middle Name (Options: show/hide, minimum characters required, label text)
  • Last Name (Options: show/hide, minimum characters required, label text)
  • Company (Options: show/hide, minimum characters required, label text)
  • Address Line One (Options: show/hide, minimum characters required, label text)
  • Address Line Two (Options: show/hide, minimum characters required, label text)
  • City (Options: show/hide, minimum characters required, label text)
  • State (Options: show/hide, minimum characters required, label text, list or input field)
  • Zip code (Options: show/hide, minimum characters required, label text, numbers only)
  • Country (Options: show/hide, minimum characters required, label text, list or input field)
  • Email Address (Options: show/hide, required or not, label text)
  • Web site Address (Options: show/hide, required or not, label text)
  • Telephone Number (Options: show/hide, minimum characters required, label text, numbers only)
  • Fax Number (Options: show/hide, minimum characters required, label text, numbers only)
  • Subject (Options: show/hide, minimum characters required, label text)
  • Reference Number (Options: show/hide, minimum characters required, label text)
  • Message (Options: minimum characters required, label text)
  • Sends the senders ip address of sender.

2- You can enable or disable any field on the form. This easily done by editing the handy settings file of the script instead of having to re-program or re-design the form.

3- Make any field a required field.

4- Important field are verified for accuracy before submit. Web site address, email address, telephone number must be what they are to eliminate spamming.

5- Give any field a minimum number of characters to be accepted as input.

6- Send a receipt to customer with a copy of his form. You can enable or disable this option from the settings file.

7- Insert a message such as a thank you note and/or signature to the top or bottom of the receipt. Easily changeable from the settings file.

8- Send the receipt from a given email address like a noreply address and receive the form to a different address.

9- Change the colors of the form from the settings file instead of messing with the code of the contact form script.

10- Your email is hidden from email search engines to eliminate spam.

11- Customize success message and error message after form submit from the settings files.

12- Change fields labels from the settings file.

13- Does not require a database. Receive the form to your email address.



Requirements:

A server able to run php with mail function enabled.

Installation:

The script runs using two files: settings.php and contactusform.php Putting these two files in the same folder on your server is actually installing the script! All that is left to be done is:

1- open the settings.php file using your favorite php editor and change at least the following three variables:

  • $website_name : So the receiver knows where the email is coming from after submitting the form.
  • $mail_to: the e-mail where you want to receive the form.
  • $mail_from: the e-mail to send the receipt from after submission. Could be a noreply@yourdomain.com or the same as $mail_to

2- If agree with the default settings, you are done. If not, go through the settings in settings.php and change them to your needs. Save the settings.php file and you are done!

3- Any where you want to use the form, place the following code (note that this code must be used in a page that is executed as php):

<?php include("contactusform.php");showcontactusform(); ?>

If you want to add the form to an existing php source code file, just after the <?php add the following: include("contactusform.php");

then any where you want the contact form to show, simply add: showcontactusform();

 

Settings:

1 - Default Settings:

  • Title: Show, Not Required
  • First Name: Show, Required, Minimum 2 characters
  • Middle Name: Show, Not Required
  • Last Name: Show, Required, Minimum 2 characters
  • Company: Show, Not required
  • Address Line 1: Show, Not Required
  • Address Line 2: Show Not Required
  • City: Show, Not Required
  • State: Show, Drop Down List, Not Required
  • Zip code: Show, Not Required, Numbers Only Accepted
  • Country: Show, Not Required, Drop Down List
  • Telephone Number: Show, Not Required, (numbers only on input)
  • Fax Number: Show, Not Required,(numbers only on input)
  • Email: Show, Required (Automatically verified on input)
  • Web site Address: Show, Not Required, (Automatically verified on input)
  • Subject: Show, Required, Minimum 5 characters
  • Reference Number: Hide
  • Message: 100 minimum characters
  • Send Receipt: Yes
  • Labels font color = Black
  • Background color = white
  • font size: 12px;
  • font family: Arial, Helvetica, sans-serif
  • font weight: bold
  • form align : center of container
  • number of lines in message box = 10

2- Modifying Settings:

  • Messages: Be cartful for the quotes at the beginning and the end of the message. These are required by php to tell the script that this is the start and the end of the message. You can add a new line to the message by adding a new line tag which is "n" without the quotes in your message.For example, in the $receipt_append_bottom variable you can add your company name and address this way:

$receipt_append_bottom = "Your Company Name n Company Address n CompanyWebsiteAddress.com n Telephone:111 222 3333 n Thank You";

Your customer will receive it like this:

Your Company Name
Company Address
CompanyWebsiteAddress.com
Telephone:111 222 333
Thank You

  • Company name and email addresses: change it the same way you change messages, only no new lines here. Email addresses must be valid emails!
  • Variables: the names of the variables are self explanatory. to enable a variable set it to 1, to disable a variable set it to 0. To make a variable required make the minimum required characters greater than 0. the minimum characters variables has no effect if show variable is disabled.
  • Special fields:
    • Telephone,Fax, zip code: you can force the user to input numbers only in these fields. Even if the field is not required, this option will still work when the user makes an input.
    • Web site and email address: The script will verify that the input is of a valid format on input automatically whether the fields are required or not.
    • States and Country: By default they are lists, if you prefer you can have them as input fields similar to name and city. As always, in both cases, to make them required, set the minimum characters to a value greater than zero.
  • Design Settings: You can change these values to make the contact form match your web site design.

Version 2.0 of this great contact form has been released with the following additional features:
a- Image verification (captcha) for even better security and anti-spam: the contact form now has the image verification feature. Like all the other features of the zeronese free contact form, all the settings of the image verification code is controlled from the settings file. For this to work for you, you will have to have the GD library installed on your server.
b- Confirmation page: instead of displaying just a thank you message, the contact form has the capability of displaying the content of a separate html file that you can design and add what ever you like in it. Also, you can disable this and display the classic than you message after a successful submission of the form.
c- Date and Time is now received in both the receipt e-mail and the email you receive. An offset can be set in the settings file if your server's time is different from your time.
e- more control over the error messages in the settings file.

Please Note if you are upgrading to 2.0:

1- seesion_start() function must be at the very beginning of the php file. this is used for the captcha support.
2- If you are not going to use the captcha verification you can delete session_start();
3- if your php file that will host the contact form already has session started, you will also need to delete session_start.

License:

The Free Zeronese PHP Contact Us Script is distributed under the under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.


These are in short these are the terms of use of this script:

Zeronese Inc. grants the right to:

1 - Use this script on as many web sites as you like.
2- Use the script on commercial and personal sites.
3- Customize the script design and structure to suit your web site needs.

Under this license Zeronese, Inc. Does NOT grant you the right to:
1- Remove the "powered by" link and note on the contact form script.
2- Distribute the code modified or unmodified claiming it to be your own work.
3- Sell the script modified or unmodified, separate or in combination with other code or project.

At any time you feel stuck, you can use the form below to post a comment or a question and we will reply to you as soon as possible. It is a good idea for you to subscribe to this question by clicking this subscribe me link, this way you will receive notifications when an update is available or a comment is posted. If you do not want to subscribe, check this page regularly for update notifications. We hope this contact form script solves someone's problem.

The version of your script is on the top of the settings file, the current version is (1.3). You can download the current version of the contact form script from here...

Rated:NR/0 Votes
9024 Views
More Articles From Webmaster Tools
More Articles From Webmaster Tools
Print Article
Print
Share |
Comments, Questions & Reviews
#1 Comment by: Anonymous Guest
2008-06-02 03:45:18
 
Can I get the script to enter something in the subject line of the receipt email?


#2 Comment by: Hassan Sayed - Zeronese
2008-06-02 09:42:58
 
Yes you can!

Open your contactusform.php using notepad or any php editor.
At the very bottom you will find two instances of the variable: $subject.

First one is:
$subject = “Message From Your Website”;
This is the e-mail subject you receive when someone submits the form, you can modify it if you need to.
Second is:
$subject = $_POST[‘subject’];
This is the receipt that is sent to the person who has submitted the form.
To modify it, just Replace
$subject = $_POST[‘subject’];
BY
//$subject = $_POST[‘subject’];
$subject = “Message You Want To Send As A Receipt Subject”;

Hope this helps :)


#3 Comment by: Tom
2008-10-09 20:01:55
 
Does the script send the senders IP address?

This is an important function I'm looking for to be able to see where the messages are actually coming from.


#4 Comment by: Hassan Sayed
2008-10-09 23:05:51
 
Good idea. the contact us form is upgraded to send the ip address of the sender. Download version 1.2 for that purpose.
For those using version 1.1, look for:
$message = str_replace("n.", "n..", $message);
add the following code right under it:

if ($_SERVER['HTTP_X_FORWARD_FOR']) {
$ip = $_SERVER['HTTP_X_FORWARD_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}

$message .= "nFrom IP:".$ip;

We thank you for supporting the free php contact us form.


#5 Comment by: Rudi
2008-11-19 02:47:39
 
Hi this looks like a great script! The question that I have is, can this script run off a normal html web page where the form would link to the settings.php file. I am not a programmer myself and I am trying to get a form that does not only have the normal name + email fill in fields but more fields for extra info from the visitor, that would work on my site. The form must also be part of my page layout and not a seperate page from the site and at the moment the source code is html and not php or another language.

Thanks
Rudi


#6 Comment by: Zeronese.net
2008-11-19 09:49:42
 
It is a great script. Thanks :)

The form can be run from an html page if the html page can execute php code.
The contact us form can be part of your page without any distruction to the design.
In your html page (that executes php) just put this line:
<?php include("contactusform.php");showcontactusform(); ?>
Your form will show there. In the settings file you can change the background color to match your web page.

Advanced Note: If you are on a linux server that allows you to edit the .htaccess file, add this line and your html page will then be able to execute php code:
<Files yourpage.html> AddType application/x-httpd-php .html </Files>

Furthermore, you can add this line in the .htaccess instead of the above and all your html files should be able to execute as php:
AddType application/x-httpd-php .html

Good luck and thanks for using our contact us form :)


#7 Comment by: Anonymous Guest
2008-12-01 00:33:12
 
I am having problems with the code. Before the form it has "/contactusform.php on line 36 Notice: Undefined index: firstname in" for every line in the form. My site URL is http://cim.saddleback.edu/~sfausneaucht0/php/1234/main.php. Please take a moment to look at my page and let me know what I need to fix to have the form working properly


#8 Comment by: Hassan Sayed
2008-12-01 00:56:46
 
This occurs if you have the E_NOTICE reporting enabled in your php.ini file.
To solve this problem, either disable E_NOTICE in your php.ini or simply add this line at the very top of the contactusform.php file just below the <?php:

error_reporting(E_ALL ^ E_NOTICE);

Not that this will not disable error reporting, but the notices such as non defined variables.
Hope that helps.





#9 Comment by: karel flip
2008-12-22 15:12:53
 
I really like this script.
The only thing I mis is the option as shown below (Enter a code or a number). Is there a way to simply add this to the ContactForm?
Cheers,
karel


#10 Comment by: Hassan Sayed
2008-12-22 15:37:15
 
If you are talking about the image verification, it is not yet implemented.
A release is planed for version 2 by January 15, 2009.
With version 2 there will be some more options such as image verification, confirmation page and some other stuff.
You might want to subscribe to this article by clicking the Subscribe Me option above and you will recive a notification when the contact form is updated.
For now make a couple of fields requiered and the form will not be submitted with out them.
Happy holidays :)


#11 Comment by: Ramón Cutanda
2009-03-06 17:15:04
 
Hi,

I'm using (well... trying to use...) the webform for an Spanish website. All special characters are not showing properly in my mail client.

What may the problem be?

Thanks in advance.


#12 Comment by: Anonymous Guest
2009-03-06 20:28:05
 
please, provide an example so we can do a test.


#13 Comment by: karel flip
2009-03-11 15:33:12
 
Hi,
Great script,
Is there a simple option to add a captcha or code you're displaying below this comment block to prevent spam sending???
Cheers,
Karel


#14 Comment by: Hassan Sayed
2009-03-12 14:17:08
 
Your prayers has been answered:
Version 2.0 of this great contact form has been released with the following additional features:

a- Image verification (captcha) for even better security and anti-spam: the contact form now has the image verification feature. Like all the other features of the zeronese free contact form, all the settings of the image verification code is controlled from the settings file. For this to work for you, you will have to have the GD library installed on your server.

b- Confirmation page: instead of displaying just a thank you message, the contact form has the capability of displaying the content of a separate html file that you can design and add what ever you like in it. Also, you can disable this and display the classic than you message after a successful submission of the form.

c- Date and Time is now received in both the receipt e-mail and the email you receive. An offset can be set in the settings file if your server's time is different from your time.

e- more control over the error messages in the settings file.

Please Note if you are upgrading to 2.0:
1- seesion_start() function must be at the very beginning of the php file. this is used for the captcha support.
2- If you are not going to use the captcha verification you can delete session_start();
3- if your php file that will host the contact form already has session started, you will also need to delete session_start.


#15 Comment by: abdularzzag
2009-04-11 18:58:07
 
Dear:sir

I want to install (Free PHP Contact Form Script ) on web site but I do not know?

Please Help Me

Thank you...............


#16 Comment by: Hassan Sayed
2009-04-11 19:24:00
 
Did you read the installation procedure on this page???
where are you stuck???


#17 Comment by: abdularzzag
2009-04-12 16:39:26
 
i can not install on page ?????????
How............


#18 Comment by: Hassan Sayed
2009-04-13 02:31:01
 
Calm down and take it step by step.
Put the downloaded files in a directory on their own. Modify the settings and see if the contact form works.

You can do that by uploading the whole contactusform folder (after unzipping it) to your hosting account.
Then point your browser to: http://www.yourdomainnamehere.com/contactusform/contactpagedemo.php
If you see the contact form, this means the contact us form works. You can now rename the contactpagedemo.php to contact-us.php or whatever fits your need.

Then you can redesign that file to fit your website design by changing the body html.

See if that helps.
Good Luck :)


#19 Comment by: brad bardstownfood.com
2009-09-27 15:12:28
 
I tried double the email option so I can ensure verificiation of correct typed email? This did nothing but cancel out the email and put my second addition called email verification...


#20 Comment by: brad bardstownfood.com
2009-09-27 16:15:21
 
I also have eveyrthing working and when I click submit button, it keeps saying invalid code for captcha. I have tried to disable this, and when I did, it took the whole form off.


#21 Comment by: Hassan Sayed
2009-09-27 20:14:19
 
Brad, I hope this helps;

1- Although this is a mod but i will try and help you do it. What i understand is that you are trying to make the user enter his email twice where the second is to verify the first entry.
To do that look, in contactusform.php around line 426 for:
else{
if($email_reuired > 0){
$error = " * ";
}
}
$form .= error($error);
$form .='</td></tr>';
}


then add after it:

$error = "";
$form .= '<tr><td width="20%" align="right">Verify E-Mail</td><td colspan="2"><input type="text" name="veriemail" id="veriemail" style="width:40%;" value="'.$_POST['veriemail'].'">';

if((strlen($_POST['email']) > 0) && ($_POST['email'] != $_POST['veriemail'])){
$error = " <== email mismatch!";
$errors++;
}
$form .= error($error);
$form .='</td></tr>';




Second Question(captcha problem): The only reason i can think of for captcha not to work is if you have missed the session_strat(); code at the beginning of your files using the form.
This code:
<?php session_start(); ?>
must be on the top of contactusform.php, settings.php, and the file you installed the form on.

Review this code in the contactpagedemo.php file and make sure it is there.

<?php
/*
note:
1- seesion_start() function must be at the very beginning of the php file. this is used for the captcha support.
2- If you are not going to use the captcha verification you can delete session_start();
3- if your php file that will host the contact form already has session started, you will also need to delete session_start.
*/
session_start();
?>

I hope that helps.

NOTE: The license of this script does not allow you to remove the powered by notice. Thanks


Good Luck :)


#22 Comment by: Anonymous Guest
2010-01-30 20:32:49
 
got an error like this. actually 2. one cookie and one cache limiter

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by


#23 Comment by: Anonymous Guest
2010-01-30 23:26:51
 
this means youy have the session_start(); function after some code. make sure that your session_start(); is the first thing after the first <?php you use in your script


#24 Comment by: Paul R
2010-03-04 03:06:06
 
Hassan,

I'm having the same problem with the Warning: session_start() [function.session-start]: Cannot send session cache limiter -

It doesn't matter where I put the <?php session_start(); ?>, contactusform.php, settings.php, or both - I get the error. But when I remove the line the captcha doesn't work, says it's invalid.

I just upgraded to 2.0 to avoid spammy bot comments. I like the script and would like to get this to work.

Thanks.


#25 Comment by: Hassan Sayed
2010-03-04 08:46:47
 
This line
<?php session_start(); ?>

must be the first line in thew script other wise it will not work wherever you put it.

The captcha won't work without the session_start() funtion.
To make further testing, in an empty file put
<?php session_start(); ?>

and try to load it, see if you see the same problem. if you see the problem, this means there are some php setting that might be wrong and i cannot debug that.
If the file runs, copy the contactform.php code (with out the session_start(); function right below the <?php session_start(); ?> and it should work!

Good Luck


#26 Comment by: au
2010-06-26 16:14:34
 
AM HAVING SOME PROBLEM RUNNING THE FREE FORM
this is the error i get when i try to run it on the net

"An error occurred while sending your message, please try again later!"

sir what could be the problem and it the solution too


#27 Comment by: Hassan Sayed
2010-06-26 21:02:17
 
My guess is that you have your email setup wrong in the settings file.
go to the settings.php file and check your $mail_to and mail_from variables.
make sure there are valid emails between the quotes and no extra spaces.

I hope this solves your problem.

Good Luck :)


#28 Comment by: phillipgrimes.com/contactusform/contak.php
2010-10-05 20:23:20
 
I like the idea of this script but the mailing functions are causing me problems. I currently do not have email set up for the domain which I have installed this form and had not intended to. I have tried to use gmail, yahoo, and msn mail servers to no avail.

Is there a way around these issues? Is it possible to simply receive the mail from my users and not need to send mail to them?


#29 Comment by: Hassan Sayed
2010-10-06 08:49:43
 
yes, in your settings.php
set the value of $send_a_receipt_to_sender to 0
so
$send_a_receipt_to_sender = 1;
will be
$send_a_receipt_to_sender = 0;


#30 Comment by: Thx
2011-02-21 19:12:22
 
hello Hassan this script saved my days :)

2 questions :)

1. can i add custom fields? if yes, how can i do it please?
2. My captcha code wont show, i have the GD library installed, but its just shown as the typical non-found img icon.

thanks!


#31 Comment by: Hassan Sayed
2011-02-21 19:30:51
 
glad the script is useful for you.
1- if you know a little php, you can add other fields by following the flow of the code and immitating it.
2- i don't know how i can help you with this, just make sure all the files are in place and i am sure you can find the solution.


#32 Comment by: execupaving.co.za
2011-07-29 05:22:13
 
1) I have downloaded the script which code do i put into my html place holder to show the form on a html page.
2) I have changed the settings
3) Where must the files and which files must be uploaded into the same as the index html ( I am useing Xara 6 )


#33 Comment by: Guest
2011-07-29 12:07:00
 
it is all on this page:)


#34 Comment by: mike
2011-09-18 17:25:12
 
hi,
thanks very much for posting this information regarding:
"Free PHP Contact Form Script Documentation"

i have just started to learn PHP.

the documentation and your explanation on that, is really great.
i've tried to download these two files (settings.php & contactusform.php)
but the "contactusform.zip" which you post doesn't contain these files (it's an unread data).

please help me and send me by email the above two files.

many thanks,
mike


#35 Comment by: Hassan Sayed
2011-09-18 20:29:35
 
I downloaded the file and unzipped it... everything seems to be fine.

my best guess since you are new to php is that you are trying to run the script as if it was a regular file.
if that is the case, you need to install php on your serve (computer) or run the script on a php capable host.

good luck :)



Comments is currently disabled for this article!
Related Articles and Readings
What do I do when I receive a FrontPage contact form error?
Error Message: FrontPage Error. User: please report details to this site's webmaster. Webmaster: please see the server's application event log for more details. Cause: This ...
Using the ASP Form Mailer
To use the ASP form-mailer, create a Web form in HTML that links to our ASP script and upload it ...
Modifying Your Contact Information for Your Domain
You can modify your domain name information at any time. To Modify the Contact Information for Your Domain Name Using the ...
I was wondering if you could give me the contact info for a particular designer?
Sorry, our corporate policy prohibits direct contacts with contractually oblidged designers. ...
Solving Download Problems
x This link goes nowhere. Make sure that you don't have firewall restrictions prohibiting this download. Try to use this link ...
The information provided in this article is for general information and/or the comments is the sole responsibility of their respective authors and does not necessarily reflect the opinion of zeronese.net does not endorse any article and/or comments published by our web users unless otherwise noted.