An exemplary form of communication with asking a question. Feedback form in PHP with sending to e-mail

An exemplary form of communication with asking a question. Feedback form in PHP with sending to e-mail

18.11.2021

Feedback form for the site which I'll show you is based on the use of Ajax technology. But do not worry, you do not need to know this, everything is ready, you just need to install this form and customize it for yourself!

Guys - the script is outdated for a long time. Someone works, someone does not. And I'm too lazy to figure it out and even more so to update. Therefore, test at your own discretion.

Php feedback form with sending to mail

This feedback form to the site very functional in itself, several plugins are connected to it that create an attractive appearance and check the validity (read correctness) of the data you entered. These plugins work on the great and the mighty! And they are called like this:

    1. JQTransform- a plugin that allows you to make our feedback form beautiful!

    2. formValidator- and this plugin checks the contact form for the correctness of the information entered and in which case it displays tooltips!

For the full-fledged work of this form, the PHPMailer class will be used. Considered one of the best!

A note for the smartest:

The feedback form for the site can be made in HTML! But it will only start working with PHP! And nothing else!

This is me for those who are looking for a feedback form only in HTML. You will do it, but it will not work!

Therefore, yours must support PHP, and for this contact form, PHP must be at least version 5. I hope I'm making it clear? Moreover, now, any normal hosting supports these conditions!

I dug up this feedback form on the website www.tutorialzine.com, the link leads directly to the original page, i.e. site of the author of this form!

Everything is in English, so Sasha and I had to tinker a little to Russify this contact form and the plugins themselves that are connected to it.

To be honest, we spent two days with this "form", as various jambs began to emerge, and I did not want to upload the unfinished feedback form, all the more so beautiful! So if you are a fan of doing everything yourself, and the thought will fit into your brightest head - to Russify this form yourself, I will give a couple of tips, since you will not be limited to simply translating phrases:

    1. This feedback form is tailored for the bourgeoisie, and downloaded from there, so it will send you instead of normal Russian symbols - krakozyably. Understand the encoding. Anyway, all "seals" will be associated with this!

    2. The validation script initially does not understand our letters, so they will need to be written there!

    3. Even after these actions, if you specify the subject of the letter in Russian, the letter comes with a subject - No subject (I hope I wrote it correctly), this is treated if you specify the encoding in the PHPMailer class file.

    4. In the original form, the text in the input fields was pressed to the bottom, not in the middle. This is a JQTransform plugin glitch.

Well, he seems to have written everything down and warned me. Let's go further!

Hello, friends! In this tutorial we will talk about creating a feedback form, or as they say among the people "Contact form".

Today we will analyze with you how you can create in a few minutes easy, beautiful and functional a feedback form using my favorite plugin Contact Form 7 .

I will try to explain in as much detail as possible all the stages of installing the contact form, and in this regard, the lesson will turn out to be quite long 🙂

Creating a contact form in WordPress

At the very beginning, I want to note that the Contact Form 7 plugin is Russified, and you will not have any problems with it. As proof of my words, the fact that this plugin was downloaded can be MORE THAN 25 MILLION TIMES !!!

And so, let's get started. To create a feedback form you need to do the following:

1. Install and activate the Contact Form 7 plugin. How to install plugins you can.

2. After activation, go to Contact Form 7 -> Forms.

3. In the window that opens copy the line with an embed code.

4. Paste the copied code on the page where we want to add a feedback form. After you have inserted the code, do not forget to save the changes by clicking the button "Refresh".

Here is such result adding a contact form to get:

Ready! You installed working form feedback to your site!

As you can see, in total in a few minutes you can easily install a feedback form on the site. You can put an end to this, but for those who are not satisfied with the standard form and who want create completely new contact form with other fields and possibilities - recommend read the lesson to the end.

In order to create a new form, you first need to determine what fields we need in it. In this tutorial, as an example, we will create a simple call back order form.

To do this, we need the following fields to be filled in the form:

  • Name (Required field)
  • Surname
  • Phone (Required field)
  • A field with a choice of a convenient time for a call

After we have decided on the fields, we proceed to creating the form:

1. Go to Contact Form 7 -> Add New.

2. In the window that opens, press the button "Add new"... If necessary, select a language from the drop-down list below. By the default language will be Russian.

3. After clicking the button, you will be taken to the page on which the form editor.

At the very top of the page is the field in which we write title new form... V Form template we see standard form fields that are created by default.

Below we see the settings of the letter that comes to your mail after someone has sent an order from the form on the site. In these settings, for example, you can change or add an e-mail, which will receive requests from the form on your site. V letter template the information that will be displayed inside the letter is configured.

4. After we have superficially familiarized ourselves with the structure of the editor, we proceed to creating our new form. For this we need DELETE from the form template all lines except for the button "Send", and in the email template delete all completely . After deleting, you should get something like this:

5. Now we need to create new fields: Name(required), Surname, Telephone(required), Convenient call time.

We start by creating a field to enter a name, which should be required. To do this, press the button "Generate Tag" and choose Text field.

In the settings of the new field, put a check mark, which is only necessary if the field should be required. Next, copy the generated code into the form template on the right, and copy the following code into the email template. See the image below for comments and arrows for better understanding.

6. After we have added a field for entering a name, click "Generate Tag" -> Text Field and by analogy create a field Surname and Telephone by copying and pasting the code into the form template and the letter template. The only difference is that for the field Surname you do not need to check the box for mandatory filling .

After adding the First Name, Last Name and Phone fields, the form editor will look like this:

7. Now we create the field Convenient call time. To do this, click "Generate Tag" and choose "Drop-down menu".

In field Choice we write in a line according to one option, in our case this time is from 8-00 to 18-00 at intervals of two hours. After filling out, copy the corresponding lines of code into the form template and the letter template.

As a result, you should get something like this:

9. Copy the form code and paste it on the page where you need the form... If you did everything correctly, you should get the following form for ordering a call back:

After the user makes a callback order from your site, a letter will be sent to your mail with the following content:

READY! Here we have created with you callback order form from scratch.

I agree that for some, everything may seem very difficult and scary, but this feeling will only last until the first creation of a contact form from scratch 😉

In most cases, a standard feedback form, which is created by the plugin by default immediately after its installation and activation, is sufficient.

I hope this tutorial was useful to you, and you figured out the Contact Form 7 plugin.

If you have any questions during the creation of the form or something will not work - write and ask questions in the comments.

And remember that feedback form on the site - a required attribute on the contact page.

Hello, friends! In this lesson we will talk about creating a feedback form, or as the people say "contact form". Today we will discuss with you how you can create an easy, beautiful and functional feedback form in a few minutes using my favorite Contact Form 7 plugin. I will try to explain in as much detail as possible all the stages of installing a contact form, and in this regard, the lesson will turn out to be quite long :) Creating a contact form in WordPress At the very beginning, I want to note that the Contact Form 7 plugin is Russified, and you will not have any problems with it. As proof of my words, the fact that this plugin ...

Overview

Vote for the lesson

100

Grade

Outcome: Dear Readers! Do not be lazy to vote and leave a comment. This way I can understand the usefulness of the lessons and articles, and improve their quality in the future. Thank you in advance!

Create a feedback form

Creating a feedback form on the site

In the process of website promotion, along with the study of statistics of visits, information about the site from the visitors themselves is of particular importance. One of the easiest ways to obtain such information is to post a page on the site with feedback form... The visitor leaves a message, and it will come to your email address or whatever you specify. At the same time, the visitor does not need to use his mail program, he does not even need to have his own e-mail.

The simplest example of such a form is shown in Fig. 1. (This is a perfectly working sample, and you can use it to send me a thank you letter.)

Fig. 1. Simple contact form

To post such a feedback form on the site, just basic information about HTML and the ability to operate with two commands is enough - Copy and Insert. Let's consider the sequence of actions for creating a feedback form (Fig. 1) on the HTML page of the site.

1. Check that your hosting plan (the office where your site is hosted) supports PHP. If not, then you will most likely have to pay extra to switch to another tariff that supports this same PHP. You do not need to search for the meaning of this abbreviation, since you will not need knowledge of PHP.

2. Let's select the page on which we want to place the feedback form and insert the following code in the right place:

Your name:




Your e-mail (for reply):




Your message:




As you can see, the whole form is created with the tag

with attributes action = mail.php(an indication of the page of the site where the script for processing the entered data is located) and method = post(method of sending data to the server). The individual lines are created by the tag with quite understandable attributes. The location of individual form elements, text, fonts, etc. can be changed in accordance with the design of your site. In the tag

Content of file submit.php:

This is where a basic check of the form is performed, so as not to send empty messages. If everything is "good" - the letter is sent. And there is a redirect to the notification page about the successful sending of the letter.

If (! Empty ($ _ POST ["name"]) AND! Empty ($ _ POST ["email"]) AND! Empty ($ _ POST ["message"])) ($ headers = "From: Roman Krotov." Reply-To: [email protected]"." X-Mailer: PHP / ". Phpversion (); $ theme =" New message from site "; $ letter =" Message details: "; $ letter. =" "; $ Letter. =" Name: ". $ _POST ["name"]; $ letter. = "Email:". $ _ POST ["email"]; $ letter. = "Phone:". $ _ POST ["phone"]; $ letter. = "Message:" . $ _ POST ["message"]; if (mail (" [email protected]", $ theme, $ letter, $ headers)) (header (" Location: /testform/thankyou.php ");) else (header (" Location: / testform ");)) else (header (" Location: / testform ");)

Well, I see no reason to post the notification page itself. There's the basic structure of an HTML document and just one line of text.

© 2021 hecc.ru - Computer technology news