Easy PHP Contact Form script is made from pure PHP, HTML and CSS. It helps your clients or customers to easily get in touch with your company.
The main features of Easy PHP Contact Form are the following:
SMTP Authentication - new in v2.0
File Attachment Upload - new in v2.0
Phone Field and Validation - new in v2.0
Redirect To Specific URL after Submission - new in v2.0
No Javascript Needed
No Technical Knowledge Required
Creating a Field with a Line of Code
Easily Integrate to your existing website
Server Side Validator
Anti-Spam Protection using 2 types of Captcha
4 Themes CSS Design Included (Aqua, Dark, Simple, Premium)
User Location Detection
Responsive Design for Desktop, Tablet and Mobile Phone
Coded in Object Oriented Programming
Multi-language Supported
Protects you from XSS and CSRF attacks
This is the file structure of Easy PHP Contact Form Script. It should look like this when you upload it to your server website.
index.php (homepage)
contact.php (supposed that this is the showcase for contact form )
img/ (contain images)
inc/ (contain scripts)
- class/ (easy php contact form core)
- autoresponder.php
- captcha.php
- config.php
- form.php
- process.php
Installing the Easy PHP Contact Form is very easy. When you purchase the script, you will receive "contact" folder. Just follow the steps below.
Step 1: Upload "easy_contact" folder to your server. (where your homepage "index.php" is located).
Step 2: Open the file where your contact form should be displayed (We assume this is your "contact.php"). Copy the code below and paste it at the very beginning before "<html>" tags.
<?php include 'easy_contact/inc/config.php'; ?>
Step 3: Copy the code below and paste it inside the "<head></head>" tags.
<?php echo '<link href="easy_contact/style/'.$contactTemplate.'.css" rel="stylesheet" type="text/css" /> '; ?>
Step 4: Lastly, copy the code below and paste it to where want to display your form.
<?php include 'easy_contact/inc/form.php'; ?>
Don't worry, using Easy PHP Contact Form, you can easily configure those metioned above with just a fews line of code. Those lines of code are well-explained in the next Configuration section.
In case that you could not follow the installation process, we included the 'contact.php' inside the file. You may also contact us via my profile at Codecanyon.
Easy PHP Contact Form made it easy for you to configure your forms. Adding many fields to your forms as you want like textbox, textarea, checkbox, radiobutton and combobox. You don't need to have HTML or PHP knowledge to use our form.
Easy PHP Contact Form is coded in Object Oriented Programming or OOP, which is the best practice in PHP coding,so adding a field to your form takes just a 1 line of code. Lets configure our form now.
All configurations to our form are merge in 1 file only which file name is "config.php". It can be found in "easy_contact/inc/config.php" (See File Structure). Open "config.php" file and edit the values there.
A configuration that contains email address in which all form data should be sent to. Place your email address inside the singe quote.
See example below:
$yourEmail = 'admin@codeadik.com';
A configuration that contains name of template for your forms design. We have 4 templates that you can use. You can create your own if you know CSS.
Possible values are 'aqua', 'dark', 'simple' and 'premium' .
See example below:
$contactTemplate = 'aqua';
A configuration for allowing to have an auto respond when a user has successfully submitted their inquiries.
Possible values are true or false.
See example below:
$autoResponder = True;
A configuration for the default subject that you will receive to your email address($yourEmail) when a user submit a form.
See example below:
$defaultSubject = 'Support from codeadik.com';
A configuration to enable or disable the redirection after a successful submission of data from form.
Possible values are true or false.
See example below:
$enableRedirection = false;
A configuration URL where the form will be redirect to after successful submission. Note: $enableRedirection must be set to true to redirect.
See example below:
$redirectToURL = 'http://google.com';
A configuration for the success message. Success message will apprear to the form when the user has successfully submitted a form. Note: Success message will only appear if $enableRedirection is disabled.
See example below:
$successMessage = 'Thank you, your message has been sent';
An error message configuration for empy field.
See example below:
$emptyField = 'This field is required';
An error message configuration for invalid email address format entered.
See example below:
$invalidEmail = 'Invalid email address format!';
An error message configuration for wrong captcha code entered.
See example below:
$invalidCaptcha = 'Please enter the correct captcha code!';
An error message configuration for user input field that exceeds with maximum character required.
See example below:
$maxAllowedCharacter = 'Maximum allowed character is ';
An error message configuration for file attachment upload which file extension is not specify in the list of accepted extensions.
See example below:
$invalidFileExtension = 'file extension is not allowed';
An error message configuration for file attachment upload which file size exceeds to maximum required size.
See example below:
$maxAllowedFileSize = 'The file size exceeds more than ';
An error message configuration for invalid phone number format.
See example below:
$invalidPhoneNumber = 'Invalid phone number, only accepts digits and phone characters';
In the previous version(v1.0) of Easy PHP Contact Form, it uses PHP mail() to send emails. Now, it has an option to enable SMTP authentication. Let's discuss the difference between PHP mail() and SMTP authentication.
PHP mail()
Advantages:
Disadvantages:
SMTP Authentication
Advantages:
Disadvantages:
It's up to you of what method do you what to use. But I recommend SMTP Authentication.
Let's start the configuration.
A configuration to enable or disable SMTP.
Possible values are true or false.
See example below:
$smtpEnable = true;
A configuration for SMTP Server.
See example below:
$smtpServer = "server.codeadik.com";
A configuration for SMTP port.
See example below:
$smtpPort = 465;
A configuration for SMTP email. This is your email address. It is used to receive data from form.
See example below:
$smtpUsername = "admin@codeadik.com";
A configuration for the password of your email address ($smtpUsername) using SMTP.
See example below:
$smtpPassword = "PaSSwOrdHere";
A configuration for type of encryption for SMTP.
Possible values are 'ssl' or 'tls'.
See example below:
$smtpEncryption = 'ssl';
If you want to use your domain email address, you can find it in your CPANEL.
You will first need to create a email account . You can do this via the cPanel interface (X3) by going to "Mail" section and clicking "Email Accounts."
Once you have created an account and are brought back to the page, click the drop down "More" next to that account, then choose "Configure Mail Client." At the bottom of the page that appears are manual settings. Use the settings "Secure SSL/TLS Settings". That's your SMTP details.
If you want to use 3rd Party email address, kindly search it on the net. We will only provide some of the common 3rd Party SMTP details.
SMTP Server: smtp.gmail.com
SMTP Port: 587
SMTP Username: example@gmail.com (This is your gmail account)
SMTP Password: (This is your gmail password)
SMTP Encryption: tls
There some steps or requirements for you to use Gmail SMTP details. Please follow the steps below:
Step 1: Log in your Gmail Account
Step 2: Enable the access for less secure apps via this link: https://www.google.com/settings/security/lesssecureapps
Step 3: Visit the link https://accounts.google.com/DisplayUnlockCaptcha, then click "Continue" button.
By doing the steps above, you will successfully receive emails in your Gmail account.
SMTP Server: smtp.live.com
SMTP Port: 587
SMTP Username: example@hotmail.com (This is your hotmail or live account)
SMTP Password: (This is your hotmail or live account password)
SMTP Encryption: tls
Like we have said earlier, creating fields is very easy with just 1 line of code. We will be using the same file above, which is "config.php" to create fields.
Before we start, we need to create an object of our form. Don't worry, you don't need to understand these. After this line of code we can now create the fields.
$easyForm = new EasyContact;
EasyContact class automatically creates an html element for you when you call its method. So you don't need html knowledge as we said ealier. Lets start creating fields.
In order to create a textbox, we need to call the method createTextBox() which accepts 4 parameters which are:
Parameters | Type | Description |
ID | String |
|
Display Label Name | String |
|
Required | Boolean |
- true means the field is required - false means the field is optional |
Maximum Character | Integer |
|
Example:
The line of code below creates a textbox which has an ID of 'fullname', which has displayed the label name of 'Full name', which is optional and has limit of maximum characters of 70
$easyForm->createTextBox('fullname', 'Full Name', false, 70);
Yes, with this line of code, we already created a textbox field and is now displaying in our form.
This email address field is a special field. It has an automatic email format validation. This field is the sender email address, probably the one who used your contact form.
In order to create a email field, we need to call the method createEmail() which accepts 2 parameters which are:
Parameters | Type | Description |
Display Label Name | String |
|
Maximum Character | Integer |
|
Example:
The line of code below creates a Email field that has displayed the label name of 'Email' and has limit of maximum characters of 70
$easyForm->createEmail('Email', 70);
You can display selection with Combox box.
In order to create a combo field, we need to call the method createComboBox() which accepts 3 parameters which are:
Parameters | Type | Description |
ID | String |
|
Display Label Name | String |
|
Required | Boolean |
- true means the field is required - false means the field is optional |
In order to create an option for combo box field, we need to call the method addComboBoxOption() which accepts 2 parameters which are:
Parameters | Type | Description |
ID | String |
|
Display Label Name | String |
|
Example:
The lines of code below creates a combo box which has an ID of 'dep', which has displayed the label name of 'Department' and it is required. It has an options 'Sales' and 'General' that is linked to combo box ID 'dep'.
$easyForm->createComboBox('dep', 'Department', true); $easyForm->addComboBoxOption('dep', 'Sales'); $easyForm->addComboBoxOption('dep', 'General');
You can display selection with Radio Button.
In order to create a radio button, we need to call the method createRadioButton() which accepts 3 parameters which are:
Parameters | Type | Description |
ID | String |
|
Display Label Name | String |
|
Required | Boolean |
- true means the field is required - false means the field is optional |
In order to create an option for radio button, we need to call the method addRadioButtonOption() which accepts 2 parameters which are:
Parameters | Type | Description |
ID | String |
|
Display Label Name | String |
|
Example:
The lines of code below creates a radio button which has an ID of 'gender', which has displayed the label name of 'Gender' and it is required. It has an options 'Male' and 'Female' that is linked to radio button ID 'gender'.
$easyForm->createRadioButton('gender', 'Gender', true); $easyForm->addRadioButtonOption('gender', 'Male'); $easyForm->addRadioButtonOption('gender', 'Female');
You can display selection with Check Box.
In order to create a Check Box, we need to call the method createCheckBox() which accepts 3 parameters which are:
Parameters | Type | Description |
ID | String |
|
Display Label Name | String |
|
Required | Boolean |
- true means the field is required - false means the field is optional |
In order to create an option for check box, we need to call the method addCheckBoxOption() which accepts 2 parameters which are:
Parameters | Type | Description |
ID | String |
|
Display Label Name | String |
|
Example:
The lines of code below creates a check box which has an ID of 'browser', which has displayed the label name of 'Browser Compatibility' and it is required. It has an options 'Google Chrome', 'Mozilla Firefox', 'Opera' and 'Safari' that is linked to check box ID 'browser'.
$easyForm->createCheckBox('browser', 'Browser Compatibility', true); $easyForm->addCheckBoxOption('browser', 'Google Chrome'); $easyForm->addCheckBoxOption('browser', 'Mozilla Firefox'); $easyForm->addCheckBoxOption('browser', 'Opera'); $easyForm->addCheckBoxOption('browser', 'IE');
The subject field is a special field just like an email field. If you did not create Subject field in your form then the default subject will be sent to your email which is '$defaultSubject' (See Default Subject in Conguration Section)
In order to create a Subject Field, we need to call the method createSubject() which accepts 3 parameters which are:
Parameters | Type | Description |
Display Label Name | String |
|
Required | Boolean |
- true means the field is required - false means the field is optional |
Maximum Character | Integer |
|
Example:
The line of code below creates a Subject field that has displayed the label name of 'Subject', which is required to fill up and has limit of maximum characters of 70
$easyForm->createSubject('Subject', true, 70);
In order to create a Textarea, we need to call the method createTextArea() which accepts 4 parameters which are:
Parameters | Type | Description |
ID | String |
|
Display Label Name | String |
|
Required | Boolean |
- true means the field is required - false means the field is optional |
Maximum Character | Integer |
|
Example:
The line of code below creates a Textarea which has an ID of 'message', which has displayed the label name of Message', which is required to fill up and has limit of maximum characters of 5000.
$easyForm->createTextArea('message', 'Message', true, 5000);
Creating Captcha protects you from getting spams email. It is a secures your forms. Our Captcha offers you two types of it: 'text' and 'image'. Text captcha works in all servers and gives you basic security for spams. Image captcha requires 'GD PHP Library' in order for this to work and not all servers have it installed. It also gives an advance security for spams.
If you don't have 'GD PHP Library' in your server, don't worry because it's a free library. Ask your hosting providers to install these for you. Here is the installation process: http://php.net/manual/en/image.installation.php
In order to display captcha, we need to call the method createCaptcha() which accepts 2 parameters which are:
Parameters | Type | Description |
Display Label Name | String |
|
Type of Captcha | String |
- 'text' means displaying text addition captcha - 'image' means displaying 4 digit image captcha |
Example:
The line of code below displays captcha which has a displayed label name of 'Enter Captcha Code' and the type of captcha is 'text'.
$easyForm->createCaptcha('Enter Captcha Code', 'text');
It can detects your customers or clients location. It returns the city and country.
In order to detect the location of your clients, we need to call the method createLocationDetection() which accepts 2 parameters which are:
Parameters | Type | Description |
Display Label Name | String |
|
Display | Boolean |
- true means displaying it to your clients. - false means it also detect your client locations but it is hidden. |
Example:
The line of code below dectects the location of client which has a displayed label name of 'Location' and it is not hidden to your client.
$easyForm->createLocationDetection('Location', true);
In order to create a file upload or file attachment, we need to call the method createFileUpload() which accepts 5 parameters which are:
$easyForm->createFileUpload('imgfile', 'Upload File', false, 1500000, array('png', 'jpg', 'jpeg', 'gif') );
Parameters | Type | Description |
ID | String |
|
Display Label Name | String |
|
Required | Boolean |
- true means the field is required - false means the field is optional |
Maximum Bytes Size | Integer |
|
Allowed File Extension | Array |
|
Example:
The line of code below creates a File upload field which has an ID of 'imgfile', which has a displayed label name of 'Upload File', which is not required to attach file, which has maximum file size limit of 1500000 bytes or approx. 1.5mb and only accepts 'png', 'jpg', 'jpeg' and 'gif' file extensions.
$easyForm->createFileUpload('imgfile', 'Upload File', false, 1500000, array('png', 'jpg', 'jpeg', 'gif') );
If you want to add a description to your file upload (optional), you must call the method showFileUploadDescription() which accepts 2 parameters which are:
Parameters | Type | Description |
ID | String |
|
Display Description | String |
|
Example:
The line of code below shows the description 'Accepted Extension: png, jpg, jpeg, gif and up to 1.5mb' that is linked to the ID 'imgfile'.
$easyForm->showFileUploadDescription('imgfile', 'Accepted Extension: png, jpg, jpeg, gif and up to 1.5mb');
Phone Field has a phone character validation. It only accepts digits, dot, dash, space and plus sign in front.
Example of accepted format:
This is only an example. It can accepts more digits.
In order to create a Phone Field, we need to call the method createPhone() which accepts 4 parameters which are:
Parameters | Type | Description |
ID | String |
|
Display Label Name | String |
|
Required | Boolean |
- true means the field is required - false means the field is optional |
Maximum Character | Integer |
|
Example:
The line of code below creates a phone field which has an ID of 'telephone', which has a displayed label name of 'Tel. Number', which is required and has limit of maximum characters of 20.
$easyForm->createPhone('telephone', 'Tel. Number', true, 20);
You can display HTML element where you want inside the form.
In order to create a HTML Element, we need to call the method createHTML() which accepts 2 parameters which are:
Parameters | Type | Description |
ID | String |
|
HTML element | String |
|
Example:
The line of code below creates HTML which has an ID of 'html1', which has a displayed HTML element of '<h3>This is html heading tags!</h3>'.
$easyForm->createHTML('html1', '<h3>This is html heading tags!</h3>');
Other Example:
You can use all html element like adding the tag with styles, class, id and etc.
$easyForm->createHTML('html3', ' <p>This is a paragraph with style. <br/> <span style="color:red">Fully</span> <span style="color:green; font-size: 15px;">customizable</span> <span style="color:blue">html</span>! </p> <hr/><br/> ');
If you enable the auto respond '$autoResponder'. You may change the auto response template in 'autoresponder.php'. It is located in '/easy_contact/inc/'. Open 'autoresponder.php' to configure it.
When the user has successfully submitted the form, they will receive an auto response to their email. The $emailResponder is the email address that will be used to send the autoresponse message.
See example below:
$emailResponder = 'no-reply@codeadik.com';
This is the subject of the auto response.
See example below:
$respondSubject = "Thank you for contacting us!";
This is the message of the auto response. It accepts multi-language characters. It accepts html format also if you want to design your auto response.
See example below:
$respondMessage = " Hello! Thank you for contacting us! We appreciate your taking the time to contact us. If your message requires a response, we will get back to you as soon as we can. Yours sincerely, Your name www.codeadik.com ";
The SMTP Authentication is discussed in the previous Configuration Section. Visit Here.
A configuration for SMTP Server of autoresponder.
See example below:
$smtpServerResponder = "server.codeadik.com";
A configuration for SMTP port of autoresponder.
See example below:
$smtpPortResponder = 465;
A configuration for SMTP email of autoresponder. This is your email address. It is used to receive data from form.
See example below:
$smtpUsernameResponder = "no-reply@codeadik.com";
A configuration for the password of your email address ($smtpUsername) using SMTP.
See example below:
$smtpPasswordResponder = "PaSSwOrdHere";
A configuration for type of encryption for SMTP of autoresponder.
Possible values are 'ssl' or 'tls'.
See example below:
$smtpEncryptionResponder = 'ssl';
The form design can be found in "easy_contact/inc/form.php".
In this file, you can change the title name and description of the form.
Modify Title Name:
<div class="header">Contact Us - Demo</div>
Modify Description:
<div class="desc">Use this form to get in touch with us. Please fill in the required field <span style="color:red">*</span></div><br />
The Regular License permits you to use Easy PHP Contact Form in one website, but you can create as many forms as you want on that website. If you want to use Easy PHP Contact Form on another website, you need to purchase additional regular license for that.
New Features Added:
Bug Fixed:
Enchanced/Improved:
Improve all PHP paths
Improve location detection
Affected File:
- "easy_contact/inc/class/EasyContact.class.php"
- "easy_contact/inc/config.php"
- "easy_contact/inc/process.php"
New Features Added:
SMTP Authentication - here
File Attachment Upload - here
Phone Field and Validation - here
Option to enable Reditection - here
Bug Fixed:
Textarea (Adding more than 1 textarea will only receive the last textarea message to email)
Autoresponder email ('n' apprears at the end of the email address)
Removed the last "," comma for input select
Enchanced/Improved:
Enchanced responsiveness in css.
Enchanced captcha responsiveness in css
Enchanced the display of (*) asterisk
- Update Documentation for New Sections "License" and "Rate Us"
New File:
- "easy_contact/inc/class/PHPMailerAutoload.php"
- "easy_contact/inc/class/class.smtp.php"
- "easy_contact/inc/class/PHPMailerAutoload.php"
Affected File:
- "easy_contact/inc/class/EasyContact.class.php"
- "easy_contact/inc/autoresponder.php"
- "easy_contact/inc/config.php"
- "easy_contact/inc/form.php"
- "easy_contact/inc/process.php"
- easy_contact/style/ (all css styles)
- fixed image captcha problem in our EasyContact.class.php
- Update Documentation for New Sections "Form Design" and "Change Logs"
- Update Documentation under "Quick Start Guide" Section
Affected File:
- "easy_contact/inc/class/EasyContact.class.php"
Once again, thank you so much for purchasing Easy PHP Contact Form Script. I'd be glad to help you if you have any questions relating to this product. I'll do my best to assist you.
If we have a free time, we can install the contact form script for you for free.
If you have more general questions relating to the Easy PHP Contact Form on Codecanyon, feel free to ask us.
Other than that, the script and documentation was created by Anthony Kwong of Codeadik.com