free php contact form
PHP Contact Form
A contact form is an essential tool in converting a user into a customer. In this article, you will get a free PHP contact form script that can be used in your website. It is responsive and will work seamlessly in mobile, tablet and other devices.
Check out the best contact form Iris that is built for high conversion to improve your sales. It is optimised for friction-less UI/UX and will result in increases enquiries. This is a professionally designed, high secure, spam-free PHP contact form.
It is built with conversion as the primary goal and it is not just about sending an email. It is the best contact form in PHP available online, check it out!
The contact form initiates a cold conversation with your user and who may become a client in the future. Importance of the best contact form on a website is almost always undermined. Building a PHP contact form is easy but building it right is difficult.
In this tutorial, we are having a PHP contact form to let the user send their queries, clarifications, feedback and more details. In this contact form example, there two PHP files handling the submitted form fields in two different ways.
In the index.php script, the posted contact form data are stored in the database. In the send_contact_mail.php file, I have created PHP code to send an email containing the submitted contact information.
This screenshot shows the output of the PHP contact form template. On this form submission, the form fields are validated and the validation response messages are displayed next to the form field label. After successful PHP processing on the contact form data, the success message will be shown at the bottom of this form template.
Contact Form User Interface
The PHP contact form UI with the Name, Email, Subject and Content fields can be shown to the user by using this HTML script. If you are looking for a responsive contact form UI, check the article.
In this HTML code, the UI is kept as simple as possible as the focus is on demonstrating the functionality of sending an email or storing the information in the database.
It includes jQuery form validation script to return validation directive with the boolean value. If the validation function returns true, then the form will be submitted to the PHP. Otherwise, the corresponding validation messages are shown in the form to let the user what is wrong with the form data they have submitted.
PHP Contact Form Input Processing
A contact form always faces spam issues. There are numerous autonomous bots that scans the web regularly looking for forms and in particular contact forms to submit spam information.
In the spam content, there will be mostly links to legitimate sites trying to promote them. There are two ways to block those spams, one by custom script implementing honeypot and related logic, second by using captcha implementation like Google reCaptcha.
Iris is a contact form that has both the option implemented. If you are looking to implement the captcha yourself, check the PHP contact form with Google reCAPTCHA article.
The index.php and send_contact_mail.php PHP files are used to handle the PHP contact form data to store into the database and to send via an email, respectively. Both of these PHP files use the same contact form template created with the contact-view.php file.
Send Contact Form Input Data via an Email
Once the email is sent to the recipient then the success message is shown in the contact form UI to acknowledge the user. You can send email using PHPMailer package and refer send email in PHP using Gmail SMTP server.
Store Contact Form data into the Database
This PHP code helps you to store the PHP contact form data into the database. Create a database table tbl_content with the name, email and more columns corresponding to our contact form fields. After getting the form data in the PHP, they will be used to form the MySQL INSERT statement.
After executing the above insert query, the contact data will be added to the database table as,
12 лучших PHP скриптов для создания Контактных форм
Контактные формы необходимы для каждого веб-сайта. Они побуждают посетителей вашего сайта взаимодействовать с вами, потенциально уменьшая количество спама, которое вы получаете.
Для бизнеса это взаимодействие с посетителями увеличивает шансы превратить их в клиентов или покупателей и тем самым увеличить доход.
Независимо от того, нужна ли вам простая контактная форма из трех полей или более сложная, которая предлагает множество опций и функций, вы обязательно найдете нужную PHP контактную форму здесь, в наших 12 лучших PHP скриптах для создания Контактных форм на CodeCanyon.
1. Quform- Responsive AJAX Contact Form
Есть причина, по которой Quform- Responsive AJAX Contact Form является одной из самых продаваемых PHP контактных форм в CodeCanyon. Эта универсальная AJAX контактная форма может быть адаптирована к форме регистрации, форме предложения или любой другой необходимой форме. Имея множество других настроек, Quform- Адаптивная AJAX Контактная Форма призвана поддерживать самого взыскательного пользователя.
Пользователь DigitalOxide говорит:
«Этот скрипт невероятный! Это очень подробные инструкции, примеры и очень много функций. Я не могу придумать ничего, что бы мне когда-либо понадобилось (в том, что касается форм), что этот скрипт не может выполнить!»
2. KONTAKTO
Пользователь vholecek говорит:
«Дизайн выдающийся, и автор очень чутко реагирует на вопросы. Я ломал голову над разработкой шаблона, и автор разобрался с ним менее, чем за 24 часа.»
3. ContactMe
Пользователь ddglobal говорит:
«Отличный плагин для контактной формы. Отличный код, разнообразие и гибкость, невероятно быстрая и выдающаяся поддержка!»
4. PHP Form Builder
Другой топ-продавец CodeCanyon, PHP Form Builder включает плагин jQuery live validation, который позволяет вам создавать любой тип формы, подключать вашу базу данных, вставлять, обновлять или удалять записи и отправлять электронную почту с помощью настраиваемых шаблонов HTML/CSS.
Пользователь sflahaut говорит:
«Отличный продукт, содержащий готовые к использованию примеры всех типов форм. Документация отличная и поддержка клиентов является исключительной, как многие другие комментировали ранее. Я очень рекомендую этот плагин, поскольку он может сэкономить много времени, особенно для разработчиков, у которых не так много веб опыта, как у меня.»
5. Contact Framework
Contact Framework уже давно существует, и с каждым новым обновлением он становится лучше и лучше. Его простой, но современный дизайн имеет три темы и пять цветов, что дает вам множество возможностей для настройки и интеграции в дизайн вашего сайта.
Пользователь fatheaddrummer говорит:
«Удивительная гибкость. Формы выглядят потрясающе. Выдающаяся поддержка клиентов!»
6. SLEEK Contact Form
Совершив свой дебют в 2017 году, SLEEK Contact Form является одним из новейших PHP скриптов для создания форм на CodeCanyon. Благодаря простому и стильному дизайну и функциональности, он идеально подходит для творческих людей или тех, кто хочет привнести немного классного стиля в контактную форму своего веб-сайта.
Пользователь thernztrom говорит:
«Именно то, что я хотел. Хорошая поддержка от автора!»
7. Ultimate PHP, HTML5 & AJAX Contact Form
Ultimate PHP, HTML5 and AJAX Contact Form заменяет чрезвычайно успешную AJAX Contact Form и позволяет вам легко размещать и управлять автономной контактной формой на любой странице вашего PHP веб-сайта.
Пользователь geudde говорит:
«Прекрасный код и безупречная документация. Я встроил форму на свой веб-сайт менее, чем за 10 минут, и большая часть этого времени была проведена в Google для reCAPTCHA. Я купил форму AJAX того же автора несколько лет назад. Новая версия намного элегантнее и легко вписывается в мой сайт.»
8. Perfect Contact Us Form
Пользователь andreahale говорит:
«Отличная поддержка и супер быстрое время отклика. Быстро помогли мне с изменениями, которые я хотел внести в форму.»
9. Contact Form Generator
Пользователь Enrico333 говорит:
10. Feedback Form
Действительно, форма обратной связи более ограничена по своей функции, чем общая контактная форма, но поскольку контактные формы также могут использоваться, чтобы оставить отзыв, я подумал, почему бы не включить в этот список настоящую форму обратной связи.
Feedback Form позволяет вашим пользователям оценивать ваш продукт или услугу и получать подробную информацию, необходимую для улучшения вашего бизнеса. Feedback Form очень проста в использовании и может быть добавлена на любой сайт за короткий промежуток времени.
Пользователь diwep06 говорит:
11. ContactPLUS+ PHP Contact Form
ContactPlus+ это чистая и простая контактная форма, которая состоит из трех стилей: не стилизованная версия, которую вы можете построить в соответствии с вашим вкусом, обычную форму с необходимой для контактной формы информацией, и более полную форму для размещения адреса.
Пользователь itscody говорит:
«Он пошел дальше, чтобы убедиться, что это сработало так, как я хотел, с очень сложным дизайном моего сайта.»
12. Easy Contact Form With Attachments
Хотя это не самая красивая контактная форма в этом списке, плагин Easy Contact Form With Attachments, безусловно, является одним из самых простых для добавления на ваш сайт. Кроме того, для конфигурации требуется только ваш адрес электронной почты и информация о компании. Форма предлагает пять различных тем на выбор и, как следует из названия, позволяет отправлять вложения файлов.
Пользователь powerj говорит:
«Отличная поддержка! Прекрасное качество кода и лучшее обслуживание клиентов!»
Заключение
Эти 12 лучших PHP скриптов для создания контактных форм только малая часть продуктов, доступных на рынке Envato, поэтому, если ни одна из них не соответствует вашим потребностям, есть много других отличных вариантов, которые вы можете предпочесть.
И если вы хотите улучшить свои навыки PHP, ознакомьтесь с очень полезными бесплатными руководствами PHP, которые мы предлагаем.
PHP Contact Form: Create Forms Using HTML & PHP
Are you ready? Let’s get started!
Many WordPress plugins come with fully functional contact forms that can be installed and used right away, but we believe in beautiful design and in your right to style it however you choose. Therefore the first video will focus on how to create, but mainly how to style, your contact form using CSS3.
Your Designer Toolbox
Unlimited Downloads: 500,000+ Web Templates, Icon Sets, Themes & Design Assets
There is not much HTML5 in this video tutorial, as the contact form is built with code available in previous versions of HTML, but you can use this first video tutorial as a way to reinforce many of the things we learned together in the previous tutorials. So without any further discussion, here it is.
Contact Form HTML and CSS Tutorial For Dummies
What you will learn:
By the end of this HTML contact form tutorial, you will have something similar to the screenshot above. Feel free to view the demo just after the video tutorial to get a feel of what you will be making in under 25 minutes. It’s a good exercise for both beginners and experts alike!
Challenge: Making Contact Form Responsive and Validation
Can you make this contact form responsive? I will give you a hint, but it will be somewhat irrelevant to a contact form, but surely you are smart enough to work your way through it, yes?
Hint: It’s all about the media queries!
Of course, it is crucial that you validate the fields so that you will not receive any unnecessary information, or secure that all the information you need from your contact form are all useful. In order to do that, you will need to include HTML5 validation in your code. It is pretty easy to do, all you need is patience and the willingness to test new stuff!
How to Make the Contact Form HTML Work
Although making it functional will require a little bit of server-side programming, I’ll be glad to point you in the right direction!
To make this form function for your website, you’ll need to code it with PHP.
Note: the PHP contact form tutorial focuses on just making it work functionally, but you will just need to add security features to it yourself (Google it!).
I am sure that almost everyone can agree on the importance of contact forms for use on everything from static HTML websites to WordPress powered websites. I found myself many times creating custom PHP contact forms for clients and always changing things around to suit the needs of the client.
After going through this tutorial, you should have a better understanding of creating custom PHP contact forms. These can be really useful in your own projects, as well as projects for clients.
I have used these for basic contact forms, surveys, and even to create simple help desk ticket systems for clients. The list is endless, just be creative. I will discuss everything that you will need to know to make your own custom HTML and PHP forms.
How To Create a Simple PHP Contact Form
First things first – To create a form in our HTML document, we will need to select the location we will be placing the form. Generally, most forms will start with:
The form action will tell this form what to look for when the submit button is pressed. In this example, we will be working with below, this is a second file that we will be creating called mail.php
The beginning line of our code that begins our form shows our action of mail.php – and the method of POST – which will trigger the PHP script to send the email when the forms are filled out, and the submit button is pressed.
Action and Method of mail.php
Using the code above – You can insert this directly into your HTML document to create the form itself. Later we will look at modifying this more and creating something a little more custom.
Contact Form PHP: How To Actually Create It?
Now we will create our mail.php file – This is what will generate the email from the form and actually mail it:
mail.php
Notice our three name tags we have created. We have Name, Email, and Message. These are the three that we created in our form. This is the information that will be sent from our contact form via email.
Add More Customization To Contact Form
Now since we have the basic idea of the contact form HTML, and tying it together with our PHP to create a basic contact form, I will begin to go a step further and now show how you can customize this form even more to fit your needs for your project.
I will show how to add a dropdown option box, and explain adding checkboxes or radio buttons for selection items to be chosen, and emailed from the form.
Adding Dropdown Option Boxes
To add a dropdown box, we will need to add the section within our HTML code to create the area for the form, as well as add the proper code to our PHP to recognize the input from the HTML and be able to send it.
Here is a simple example HTML contact form dropdown box:
In the example above, we have created a dropdown box with options 1 through 4. The option value will be what is actually submitted, and the Text within the will be what the user actually sees when making a selection. Remember that this will need to be inserted into your HTML document within the form fields.
Here is an example of the completed HTML contact form we have created with the dropdown box included:
HTML Contact Form with Dropdown Box
Now we will need to change our contact form PHP to make sure the information from the HTML form is rendered and submitted to the provided email address.
Let’s take a look at our modified PHP that will now have the dropdown box readable.
The size option lets you select how many rows will be viewable at one time. The most general setting for this is “1” but you can change it to more if you would like.
Adding Radio Buttons and Checkboxes To a Contact Form
To add Radio Buttons and Checkboxes, the same will apply as the above. We will need to add it within our HTML code, and then modify the PHP to take the input from the contact form HTML and properly send it.
Here is an example of the HTML code for adding Checkboxes:
Full Example Using All Elements In Contact Form
For this example I have changed some of the names to we can create a custom contact form for our completed example now that we have a basic understanding of the way it works.
Our HTML Contact Form Code
And again, our PHP that will correspond with this HTML form to make it work:
Our completed PHP Contact Form Code
Customizing the Thank you Message on Contact Form Success
Now for the final part of this tutorial, I will explain how to customize the very last line of our PHP script we have created. The basic way will just echo “Thank You” on our screen, but we need to make a better way so our viewers can easily have a way to get back to another page.
This will be useful in creating a custom page redirect, or a link to bring the user to a different area after completing the form. Remember that when working with PHP, some of the HTML will be different as to not disrupt our PHP code.
We will need to use single quotes “instead of double quotes” within this one, so we don’t end our PHP arg.
We will be adding a space after the “thank you” message, and adding a link back to our “form.html” document (Or whatever link you wish to create) – and also changing the color of the link using inline styles.
Let’s take a look at the modified echo command in our mail.php file:
You can play around with the example above to create your own thank you message for your site. Inline styles are not required; I just used them for this example instead of including a stylesheet. Remember that the echo command is only seen on a successful send of the message. Otherwise, the error message is sent.
Download The Contact Form Files
I am providing the download for the completed form for you to play with. Feel free to use it any way you wish, and customize it for your own projects. There are still many other things that can be done with PHP for your contact forms.
One that you might want to consider is CAPTCHA, which prevents spam email. You can also customize the other portions of the form and create your own! Have fun, and I hope that everyone has enjoyed the article and finds it useful for their own needs.
You can download the example files by clicking [HERE]
Note: I have included a few styling examples using CSS in the demo download. This will allow you to see the forms styled and understand how to style them using CSS.
This post may contain affiliate links. See our disclosure about affiliate links here.