PHP Contact Form Module
Download and learn how this simple PHP Contact Form Script was made. Technologies used include PHP OOP, MySQL, Bootstrap and HTML5.
Script Overview
This source code will enable you to add a 'contact form' feature on your website. This source code is a very good starting point if you're trying to build your own 'Contact Form Script' from scratch and add some more complex features later.
This is because the basis of this source code are our step by step and easy to understand tutorial. Specifically this tutorial: PHP, MySQL and OOP CRUD Tutorial – Step by Step Guide!
The system looks simple. But I assure you that when you study the source code, you will learn a lot of useful PHP coding techniques.
Some include: How to send a message to a valid email address from a web form, use of settings for your contact form, collecting and storing customer messages on your own database, admin restrictions and more! You can see the detailed list of features on section 6.0 below.
Is This Code For Me?
The source code in this page is NOT for you if:
- You are already an expert in PHP & MySQL programming.
- You have a lot of time to code the listed features of our PHP contact form script
- You are not that interested in learning PHP & MySQL programming.
But, this SOURCE CODE is FOR YOU if:
- You want to SAVE a significant amount of development time.
- You want to develop your own PHP contact form script from scratch.
- You determined to learn how to make a this web application feature in PHP & MySQL.
- You need some guidance in learning about this script (I'll personally support you & answer your questions)
But if you are an expert in PHP & MySQL programming and would like to take a look at our code, please do so! We’d love to hear your response and great insights! The comments section below is always open for anyone with questions and suggestions.
Pre-Requisite
Before you download, please make sure you have basic understanding of the following topics.
a. PHP, MySQL and OOP CRUD Tutorial – Step by Step Guide!
b. Apache .htaccess RewriteRule Examples
Once you learned our tutorials above, this source code should be easy to understand.
Output Preview
Below are some screenshots of our script's output. You can click an image to view the larger version of it.
Please note that the following images are just output previews. New features might be added already the time you are reading this.
[espro-slider id=6269]
Database Design
Our database name will be "php_contact_form", and we will have three tables: Messages, Settings and Users.
File Structure
The following folders and files are included in our source code. It will have more meaning if you will see the code inside the folders and files.
├─ admin/
├─── delete_message.php
├─── index.php
├─── layout_foot.php
├─── layout_head.php
├─── login_checker.php
├─── navigation.php
├─── paging.php
├─── read_message.php
├─── read_message_template.php
├─── search_messages.php
├─── settings.php
├─ config/
├─── core.php
├─── database.php
├─ dev/
├─── php_contact_form.sql
├─── readme.txt
├─ images/
├─ libs/
├─── css/
├────── bootstrap/
├────── font-awesome/
├─── js/
├────── bootbox.min.js
├────── custom-script.js
├────── jquery.js
├─── php/
├────── pw-hashing/
├────── utils.php
├─ objects/
├─── message.php
├─── setting.php
├─── user.php
├─ .htaccess
├─ contact.php
├─ index.php
├─ info.php
├─ layout_foot.php
├─ layout_head.php
├─ login.php
├─ logout.php
├─ navigation.php
What People Say?
Here's what people feel about our work and source code downloads.
"Wow, I love you guys! The best web programming tutorial I’ve ever seen. So comprehensive, yet easy to follow. I love how you combine all necessary elements in such a neat structure."
"The fact that you’ve put it all together saves so much time and its worth buying the code. Makes me feel good supporting a developer like yourself. Keep up the good work!"
"Thanks for making these awesome tutorials! I bought your source codes. To be honest, it’s very readable code and helps me understand a lot of things and how it’s done in PHP. Thanks for that again."
Features List & Download - PHP Contact Form Script
FEATURE | PHP CONTACT FORM SCRIPT |
Learn more techniques when coding with PHP, MySQL and OOP | YES |
Save your precious time coding and searching about how to do the features below. | YES |
PHP PDO and Prepared Statements | YES |
jQuery enabled | YES |
Bootstrap enabled | YES |
Font-awesome enabled | YES |
Buttons are displayed with appropriate icons | YES |
CONTACT FORM | |
Name field | YES |
Email field | YES |
Subject field | YES |
Message field | YES |
Client side validation (HTML5) | YES |
Server side validation (PHP) | YES |
Display contact email from settings | YES |
Display contact number from settings | YES |
Display contact person from settings | YES |
Store customer message to database | YES |
Send message to contact email (email set in the settings) | YES |
Send confirmation email to customer | YES |
Sending email can work via localhost using the PhpMailer library | YES |
FORM SECURITY | |
Uses htmlspecialchars($_SERVER["PHP_SELF"]) for form action | YES |
Made sure $_SERVER["REQUEST_METHOD"]=="POST" | YES |
Sanitize each submitted field with htmlspecialchars(), strip_tags() and trim() functions | YES |
Require value for each field | YES |
Show an error message under input fields if value is missing | YES |
Validate email address format | YES |
Keep values in the form if there are any error | YES |
MESSAGES | |
List messages collected from customers using the contact form | YES |
Display name, subject, sent and action columns | YES |
Unread messages in white row background | YES |
Read messages in gray row background | YES |
Pagination of messages | YES |
Search messages by name, email, subject and message fields | YES |
Read a message | YES |
Delete a message | YES |
SETTINGS | |
Setting for contact firstname | YES |
Setting for contact lastname | YES |
Setting for contact gender | YES |
Setting for contact email | YES |
Setting for contact number | YES |
Decide if you'll show contact name | YES |
Decide if you'll show email | YES |
Decide if you'll show contact number | YES |
USER | |
Login using email and password | YES |
Log out user | YES |
Hashed password stored in database | YES |
Logged-in user name display on the right side of navigation bar | YES |
Log-out button displayed on drop-down when user name was clicked | YES |
Messages can be read by logged-in admin. | YES |
Messages can be deleted by logged-in admin. | YES |
SUPPORT AND UPDATES | |
Free support for 6 months. | YES |
Free source code updates. | YES |
[purchase_link id="16101" text="DOWNLOAD SOURCE CODE NOW" style="button" color="green"] |
Simple Set Up
By now, you were able to download this (PHP Contact Form Script) source code. Here are the few instructions about how to run it.
1. Copy the extracted files to your localhost or upload it to your webserver.
2. You have to create your database using PhpMyAdmin, name of the database: php_contact_form
3. Import the SQL file called "php_contact_form.sql" located in the "dev" folder.
4. Change line 7 .htaccess file (No changes should be made if you put the files on the root directory of your localhost)
RewriteBase /YOUR_ROOT_DIRECTORY/
5. Run the login.php file on your browser, use the following user credentials.
Username: [email protected]
Password: ninja12qw!@QW
6. To see the contact form, run contact.php
Related Source Code Modules
You can download the PHP SHOPPING CART SYSTEM by modules. Learn more by clicking any 'View Module' button below.
Modules | Action |
---|---|
PHP Login & Registration Module | |
PHP Shopping Cart Module | |
PHP Product Catalog Module | |
PHP Content Management Module | |
PHP Contact Form Module | |
PHP PayPal Integration Module |
Thank You!
Thank you for reading about this PHP Contact Form Script source code and supporting our projects here at codeofaninja.com!
If you have any questions, comments or suggestions, please do not hesitate to contact me.
a. Send me an email. My email address is [email protected]
b. Go to https://fb.com/codeofaninja and chat me up.
Hi! I'm Mike Dalisay, the co-founder of codeofaninja.com, a site that helps you build web applications with PHP and JavaScript. Need support? Comment below or contact [email protected]
I'm also passionate about technology and enjoy sharing my experience and learnings online. Connect with me on LinkedIn, Twitter, Facebook, and Instagram.