How to set up smartphones and PCs. Informational portal
  • home
  • Iron
  • The ideal order form for an online store. The simplest form of sending data to mail using HTML and PHP

The ideal order form for an online store. The simplest form of sending data to mail using HTML and PHP

Now on every site you can find a feedback form, be it a commercial or information site. Unfortunately, most website owners make the forms awkward to fill out or show them too intrusive, ruining the overall impression of the company. Let's figure out where and how to properly request user data so that it is easy to interact with the site.

The main types of forms for the site

Let's consider the features of each type so that you can choose the ones that are suitable for your site or use the list as a checklist so as not to forget to place them all.

  1. Callback order form

    We recommend that all commercial sites use this form. Ideal placement is the header of the site, next to the phone number. Moreover, you should not show the input fields right away, it is better to hide them under the "Order a call" button and display them after a click. It is not necessary to make the button bright, in the form of a link it will be just as clearly visible:

    In the expanded version, two fields "Phone" and "Name" are enough and where only the first is required:

    You can leave only one field for entering a phone number, which is also quite a working option, although each client will have to first ask for a name when calling:

    Also, the callback form will come in handy in the footer of the site, place it next to the contact information. This way, after viewing the page, customers don't have to go back to the beginning.

  2. Consultation form

    "Rescue form" for those users of your site who could not find the information they need on the page, but want to place an order. It is better to place in one of two options: either minimized in the lower right corner of the screen, or expanded - at the bottom of the Main page and on the pages of the catalog of goods or services.

    The first placement option (example from the Tango and Cash website):

    The second placement option (example from the Okna-dpa website):

    This form is often replaced by an online consultant, which is basically the same thing, but you need to understand that you will need an employee who will support it.

    Also, this form should be placed on the contact page. Be sure to add a comment box so that users can tell what issue they are contacting the company about.

    Feedback form on the YouDesign contact page:

  3. Service order form

    Obviously, the form must be placed on the service page, best of all at the end of the page, after the description of the work, results and prices, in order to direct the user to fill out an application after reading the information. Form fields can be displayed immediately, expanded after clicking on the button, or redirected to the personal account on the corresponding page.

    Often on the pages of services they place a form for ordering a call back or consultation, which is not entirely correct. The client has already chosen a service page, perhaps even a tariff, and he is shown a general form, where there is no selected information. This is disorienting. We recommend specifying the following fields:

    • "Type of service" or "Rate" - it is better to fill in this field automatically or place it in the form of text at the beginning of the form
    • "Name"
    • "Phone" - make this field required
    • "Email" - to duplicate information about the order to the client
    • "Comment" - perhaps the client has clarifications

    Each business is individual and you may need additional parameters, but we recommend placing no more than 5-7 fields so as not to alienate the client. If, nevertheless, a large number of fields cannot be avoided, then visually group them by subject in order to reduce the number of errors when entering information. An example of a simple order form on the website of the Stroy company:

  4. Goods order form

    It is better to show such a form to the user on the cart page when he has decided on the choice of goods. If you have a personal account on your site, then you will have to work out two forms: for authorized and unauthorized users.

    For new clients. Don't force them to register to return to the order. This will only push them away. It is enough to add a few fields with contact information. Ask for name, phone, email and delivery address. So the user does not have to perform unnecessary actions, and you will get a new client. By email, you can make automatic registration and send the client a password by mail.

    An example of placing fields in a form for new users on Ozon:

    For old clients. Those who re-order have already indicated all the contact information, so in addition to the list of goods, the form should contain only items for choosing delivery and payment. And if you use promotional codes, then add a field to enter them, but no more. No need to re-ask for customer contacts.

    The order form for Wildberries, where the previous choice of delivery and payment method is even displayed (but leaves the opportunity to change them):

    Many people split the delivery address input into several fields, separately requesting the zip code, city name, street, house number, etc., which looks very cumbersome. Anti-example from the Angora website:

    Users make mistakes even in such forms, so it is better to leave one common field for entering the address and check the correctness of the data from new customers by phone.

    Mandatory fields for entering should be contact information, delivery address, choice of delivery and payment method. The form can be displayed in stages, but it is not forbidden to show all the fields at once. The main thing is to visually divide them into semantic groups.

  5. Registration form

    We recommend that you separate it from the authorization form, because many new customers are disoriented by the "Login" button. Two links side by side will not take up much space and will reduce the search time. Also, the form should always be visible, so it is better to mark it up in the header of the site. The most common option is in the upper right corner in the form of a link (example from Aqua-Viva):

    In general, the form should contain the same fields as the order form (and the required input fields are the same), so we advise you not to overload it with unnecessary paragraphs and fill out a general field for the address. Remember that registration is an additional step for the client, so don't push him away with a long list. You can ask the date of birth to send congratulations and discounts, but making the client come up with a nickname or indicate an additional phone number or address is unnecessary.

    It is a great practice to invite clients to register through social networks. This way the client does not have to come up with a password and, in general, registration will be faster. An example of using this feature on the Asos website:

    This online store is foreign, therefore popular social networks of those countries are given, for the Russian-speaking audience it is better to remove Twitter and add buttons for Vkontakte, Odnoklassniki.

    A personal account is best suited for online stores to store customer contact information, order history, information about discounts and bonuses. Also suitable for subscription services, for example, if you provide access to watching movies in the original.

    At the same time, if you sell industrial goods, when each order is accompanied by a call from a specialist, then there is no point in either the basket or the registration form. Sites that provide services, for example, for the design or renovation of apartments, also most often do not need a personal account.

  6. Authorization form

    Password recovery is most commonly done by email, sending the client a link to the new password entry form. Generation of an automatic "temporary" password forces the user to look for the password change form himself, which is inconvenient and only unnecessary troubles for the client. This is best avoided.

  7. Newsletter subscription form

    We have written about the benefits of email marketing more than once and gave advice on its development, for example, in this article and its second part, the most detailed information. Therefore, the subscription form is a must-have if you want to use this channel to attract customers.

    The form should be placed on the Home page so that the user immediately sees that there is such an opportunity. Better after all the basic information, at the bottom of the page (example from Lavkalavka):

    If the site has a blog, and in letters, in addition to goods and services, you announce new articles, then you can add a form on the general page of the section, for example, to the right of the articles, as did Vkusnosti by Mado:

    In the subscription form, of course, you need the "Email" field, and you can also ask for a name to make emails more personalized.

Now that we have decided what forms and where to place on the site, we will figure out how to make them more convenient to fill out.

  1. Forms in pop-up (modal) windows. They should be displayed only after the user clicks on the desired link or button. No pop-ups when opening the Home page or when customers try to leave the site. An online consultant should also not "jump out" offering to start a chat. This kind of thing annoys and repels users. Anti-example from Delicat-Servis (now the guys have removed this problem, and the form is revealed only after a click):
  2. Using animation. Let's highlight it as a separate item, since this is a common problem. The form should not flash, bounce around the screen, or float to the middle of the screen to grab attention. Such animation prevents the user from exploring the main content of the page and annoys with long viewing. Make the buttons on the forms contrasting, and then the client will definitely not miss them.
  3. Form name. Always sign forms so that the user can see what they are filling out. It is correct when the name of the tariff or service is written in the title, but if the title is too long, then add this information in the form of text below, as Fullhousedesign did:

  4. Name of form fields. It is best to place the field name above it, and already inside the field indicate an example of filling. If you place the name inside the field, then it will be erased when filling out, which is not very convenient. It is also a bad option when the names are on the left and the fields on the right, the eyes have to correlate the columns with each other (a bad example of the form on the website of the Moscow House of Books):

    A convenient option for the location of signatures and tips (on the Xarakiri.ru website):

  5. Required fields. Always mark * required fields. Above, when describing the forms, we indicated which ones to choose. The exception is forms with one field - and it is so clear that it is required. An example of highlighting required fields from the Izto company:
  6. Form errors. Users often make mistakes and don't notice, so we recommend adding input checks for contact information and required fields. It is best to display error messages as text next to the appropriate field. They should not disappear or overlap input fields. You can highlight the field with a red border, but the message must also be present. An example of clear error messages from Aristo:
  7. Confirmation of sending data. After the customer has filled in all the fields and clicked the submit button, a prominent confirmation message should be displayed so that they don't try to fill out the form again. You can use modal windows or, if the form is already in a pop-up window, place the appropriate text under the submit button. Also, the message should indicate when exactly the specialists will contact the client or what to do next. A simple "Thank you, data sent" is not enough. An example of a detailed confirmation of shipment from the Cable Systems company:

  8. Using "captcha". We do not recommend using check for a robot in forms, as it forces users to perform unnecessary actions and may even lead to leaving the site. Use protection methods that are invisible to users, for example, track the time for filling out a form on the server (if it is too short, then a robot fills out the form), add hidden fields (which only a robot can fill in), use anti-spam services for verification, etc. ... As a last resort, you can use Google input validation:

  9. Saving data. Perhaps the client accidentally closed the form, an error or reload occurred, and so that you do not have to enter the data again, save it before submitting it. This tip especially applies to long forms.
  10. Data reset button. Under no circumstances place it next to the submit button so that the user does not accidentally click on it. Place it in another part of the form, or remove it altogether. An example of a bad button layout on the Avarit website:

  11. Personal Data Law. To avoid fines for collecting personal data of clients, it is necessary to prepare regulatory documents and write about it on the website.

Outcomes

Each form should be approached individually, so it is impossible to describe all cases in one article. The main principle that should be followed is a minimum of fields. It is better to call the client and clarify the details verbally than to have him fill out long forms. Perhaps the client has some additional questions, then by calling you will solve two problems.

We hope that our recommendations will help you create convenient forms on the site and collect more orders. For those who want a personal analysis of the usability of forms, we recommend using this service.

P.S. If you need information on how to create forms (the technical side of the issue), you need recommendations on code, convenient constructors, etc., then write questions in the comments, we will make a separate article on this topic.

It has become a necessity for the owners of Internet resources. The feedback form is a convenient feature that helps the user to establish contact with the author of the site.

So, in this post, you will learn how to quickly create a simple contact form without knowledge of HTML, CSS, PHP and chemistry. This form is ready to use without any hassle.

Well, let's get down to creating a simple HTML contact form.

Method-1

Step # 1
To create an HTML feedback form for a site, you should create a file with the extension ".PHP". Name the file "mail.php" and paste the following script into it:

So, line number 1 - here you specify the address of the main page. After sending the message, the visitor will be automatically redirected to the address that you specify. Also indicate the time after which the visitor will be redirected to the main page (I have 6 seconds).

line # 2 - display encoding UTF-8

line 11 is the most important line! In this line you should enter your e-mail box to which you want to receive messages from the site.

Step # 2
Paste the ready-made feedback form code between the tags in a new file and name the file, for example "kontakt.html".

Feedback form..php "method =" post ">

Your name*

Email*

Message subject

Message text:

in line 2, specify the path to the file "mail.php", in my example it is https: //site/mail.php

That's all. If you stop at this stage, then your feedback form will work on the site, but its appearance will not be very attractive. This is fixable - you need to add styles to the form in a CSS file.

So, insert the following code into the "style.css" file:

#submit (font-family: sans-serif; color: #ffffff; font-size: 18px; padding: 0px; text-decoration: none; box-shadow: 0px 1px 3px # 666666; -webkit-box-shadow: 0px 1px 3px # 666666; -moz-box-shadow: 0px 1px 3px # 666666; text-shadow: 1px 1px 3px # 666666; background: -webkit-gradient (linear, 0 0, 0 100%, from (# ce1515), to (# 8b0d0d)); background: -moz-linear-gradient (top, # ce1515, # 8b0d0d);) #submit: hover (background: -webkit-gradient (linear, 0 0, 0 100%, from (# 8b0d0d), to (# ce1515)); background: -moz-linear-gradient (top, # 8b0d0d, # ce1515)) #respond input, textarea (-webkit-transition: all 0.30s ease-in-out; -moz -transition: all 0.30s ease-in-out; -ms-transition: all 0.30s ease-in-out; -o-transition: all 0.30s ease-in-out; outline: none; padding: 3px 0px 3px 3px ; margin: 5px 1px 3px 0px; border: 1px solid #DDDDDD;) #respond input: focus, textarea: focus (box-shadow: 0 0 5px rgba (81, 203, 238, 1); margin: 5px 1px 3px 0px ; border: 1px solid rgba (81, 203, 238, 1);)

This is the kind of feedback form you should get if you did everything as I described.

If on your form, instead of normal readable words, you see caracas, as in the example below:

then open the file "mail.php" and "kontakt.html" via free and in the menu go to
"Encodings" => "Convert to UTF-8 without BOM"
.

Method-2

You can make only one feedback file with the "php" extension, for example, with the name "kontakt.php", and in this file add all the codes, scripts and styles that I described a little higher. But still we will make some changes in the code. It will look like this:

Link design , and you can continue your browsing ";) else (echo" Error, message not sent! ";)) else (echo" Filled in all fields !!! ";)?>

Feedback form.

Your name*

Email*

Message subject

Message text:

Attention: I repeat once again: you must save this file in the "php" extension, otherwise it will not work.

Pay attention to the line in the code number 70. As you can see, I left the "action" blank, since the feedback form handler itself is located on the same file.

That's all!!! I hope the simple HTML feedback form for the site was really simple for you.

Did you like the post? Help others learn about this article by clicking on the social media button ↓↓↓

Get Blog Updates !!! Subscribe:

Latest news categories:

Popular articles:

274 Replies to a Comment - Simple HTML Feedback Form for a Website

    Where to load mail.php and kontakt.html later and how to display the form on a separate page?

    mail.php and kontakt.html upload to the hosting where your site is located. To be more precise - to the root of the site.
    kontakt.html is already a separate page for the form (example # 1). Maybe I misunderstood you?

    Nikolai answers:
    06/10/2016 at 13:39

    Stepan thanks for the working feedback form. I had it before, but returning to the site did not work. And yours works! My old one stopped working and put yours. It turned out that since May 18, the mail has introduced strict measures to combat spam and stopped receiving letters from the site. I had to switch to Yandex Mail there everything is in order for now.
    I am only worried that there is no captcha in your form. Can you tell me how to add it to the same form?

    Hello Nikolay! You gave me an interesting new topic. I think this week I will be posting a couple of articles on the topic of “simplest for a feedback form”.
    Can you wait?

    Dmitry replies:
    06/23/2016 at 05:15

    Stepan thanks for the wonderful script! Everything is super! But there is one problem, the text comes in the form of black squares (yutf checked) what could be? thanks in advance!

    Semyon answers:
    04/11/2016 at 22:06

    It is worth saying that there is another way to place a feedback form on your website - this is to use an online service that provides a visual web form designer. For example, I like the Russian-language service - formdesigner.ru. As for me, this is a great option for beginners who lack programming skills.

    Hey! Thanks for the interesting article! Please write what to change in style.css to increase the size of the data input fields.

    Understood. Thanks!

    Hello Stepan. Did everything as indicated, but no messages are sent. What could be the problem.

    Thanks for the answer. I figured out the first way, everything works. My
    there was a mistake. And how to make the sending message be
    pop-up instead of in a new window. Thank you if you answer.

    Hello Stepan, my messages are not sent, they write Error, the message was not sent, I did everything as written and changed the mail, and this is both in the first and second cases

    Hello Stepan, the files are hosted
    file extension in html and php and not working

    $ mes = "Name: $ name \ nE-mail: $ email \ nSubject: $ sub \ nText: $ body";

    What is wrong here please tell me in kontakt.html changed the names of the forms instead of the subject of the message became the phone number and instead of the text of the message the sending address

    the following error comes out Parse error: syntax error, unexpected T_STRING in /home/rxlwxpct/public_html/mail.php on line 12

    Good afternoon, Stepan! In the received letter, only English letters and numbers are displayed. Instead of Russian letters, it is printed: ???????

    Hello Vitaly! There may be a problem with the encoding of the “mail.php” file. The encoding must be UTF-8, to do this open the text editor Notepad ++. In a text editor, go to the top menu on the "Encodings" tab => "Convert to UTF-8 (no BOM)". Read about the encoding.

    Vitaly answers:
    06/26/2014 at 09:05

    I did everything according to your instructions, but the situation has not changed (instead of Russian letters, krakozyabry are displayed) ...
    In the general settings of the site, I have indicated: the encoding used on the site: windows-1251. Does this somehow affect the result?

    I am using the first method. Downloaded mail.php and created a static page with kontakt.html file. Everything works, only there is the problem I indicated ...

    Stepan, I opened the mail.php file in the notepad ++ editor and went to the "Convert to UTF-8 (no BOM)" tab. But it didn't help ... I also changed my mail from mail.ru to yandex.ru. The same result: instead of Russian letters, krakozyabrs are printed ...

    Vitaly, you are doing something wrong! Everything works!


    I sent you a link in your mail. Give it a try, fill out and submit the form.

    Vitaly answers:
    06/30/2014 at 22:21

    Stepan, your form is working great. Well, I did something wrong ... Tell me: what?

    Stepan, excuse me for the annoyance, but I really want to figure it out ... I can't do anything with your files. Something I am doing wrong ...

    Stepan, can you please tell me step by step what should I do with the file (1.html) to create a static page?
    I just copy all the code and put it in html on a static page and then save it. Maybe I'm doing something wrong?
    Also, I didn’t figure out where “style.css” should be inserted, respectively. the code…

    hello! please tell me, but if the site is not yet hosted, but I still have it in the process of creating it on my hard disk ... I installed the form but the message does not come to my e-mail

    Hello! Thank you very much for the form, I used method # 1, everything works great. But maybe there is a way to make the message that the message was sent appear on the same page?

    Hello, thanks for the form, it came up very well for the site, but there is a problem, after clicking the send button, no message is sent, but this mail.php file is downloaded to my computer, why is this? Thank you =)

    all i got it, my host doesn't support php ... thanks =)

    Stepan, hello again. Please tell me, where is the message about the successful (or not so good) sending of the message displayed? I did it according to the second method, everything worked out, letters come, but there are no messages
    Thank you.

    Good time of the day. Great article! Everything is very clear! Great, I spent 4 days looking for how to make the form very detailed and easy. Your site is just a highlight on the Internet. I have a question for you Stepan. The fact is that I do not want to go to the start page after sending the message. You can do something to just pop out the message - your message has been sent. Is that all?

    Stepan thanks, And the last question. So I want only to be able to send a message without names and email. I will get a code like this

    Message text:

    And when you send me a message, it turns out that

    “You have not filled in all the fields, go back and fill in the required fields!”

    Strange, what's wrong? And when everything works with the name and email.

    And where else can you change the width? in css? please tell me which line

    Here is my form, words cannot be thrown out of the song. Can you correct your php processing code for my form? I tried to replace it myself, it still gives an error when filling out. Help me please!)

    Order form

    Fill out the feedback form and we will call you back!

    DISPLAYS THIS AFTER SENDING. WHY?
    I did not insert the form code into a separate file, but immediately into index.html where all the menus and content are located. I inserted contacts into the section. Self-written site

    Happy New Year, Stepan, and many thanks! For several days I tried in different ways to establish the feedback form, today it finally worked! Only why, when the “subject” field is empty, the letter is not sent, but an inscription appears that it is necessary to fill in all the fields. Isn't “subject” an optional field? And if necessary, this field can be deleted, right?

    Stepan, thank you for the form!
    I plan to do it in 2 ways. I just can't figure out what to insert into the file of the site page. I will place the file.php in the root directory of the hosting, but do you need to write something on the page where the form is located? In the html file itself, insert some code, no?

    Thank you, Stepan
    Unfortunately, nothing worked out for me.
    I'm clearly inserting something wrong into the body of the site ((

    Stepan, I have created a new php file. Where I copied what was written in method 2, replaced the necessary lines.
    Uploaded to hosting.
    The form should be reflected in the index. my site This file is my html. After all, something must be written in this file in order to access the php file?

    I read all this very carefully and, of course, understood quite differently))))
    Thank you, I'll try to write))))

    Unfortunately, all the same, some kind of crookedness turns out ((

    I checked your site, but could not look at the crooked-shape.
    Have you put in a different shape? By the way, captcha does not work on your form.

    Good day!
    I write that the message has been sent.
    But the letter doesn't arrive in the mail.
    What could it be?
    I did everything as written ...

    The problem is solved, it was in the test hosting.

    Thank you. It turned out clean and everything works.

    And neither the first option nor the second works for me. PHP files
    from hosting [address deleted] said that the problem is not with them
    I put my email address

    Hosting confessed after much torture that their joint
    Wrote what – There was a problem with your account configuration.
    It works now.
    The problem is different now
    It works on the site with the ..ru extension, and
    on the site with the extension .рф does not want.
    Hosting swears and swears that the problem is with the code

    After sending, an error appears on the site, or does it just not arrive in the mail?

    in short, the problem is only in hosting.
    We wrote the answer—- We have restored the ability to send letters from the sites of your account.
    Immediately a question, after which they restored ... ...

    Super it turned out everything from the first time to set up on the vehicle!
    Only now I check my normal letters when I send it, but I try it on another computer and I write kryakozyabry

    Question! you can do something so that when filling out the form where you write E-mail, if you write something from the bulldozer, for example, numbers or something else ... I gave an error “Enter your E-mail correctly” like tago

    Hello Stepan. First of all, thanks for your blog. For me it's like a textbook, I always visit your site. A lot of useful things. I have such a problem. I took the code from you and created a simple feedback form. Everything works and the letter arrives. That's just the trouble. The letter reaches without text. Blank letter. For what reason, I cannot understand. Please help me figure this out. Thanks in advance. From SW.Akif

    Hello Stepan. A question arose: can the quality of sending letters depend on the hosting?
    Some of my letters come, and some don't, and only letters came in which were either Latin or numbers. Letters completely written in Cyrillic never came. Thanks in advance.

    Hello Andrei! Have you checked letters in SPASM?

    Andrey answers:
    07/13/2015 at 13:06

    Yes, I did. There was nothing there.
    Letters come, only written exclusively in Latin, or in numbers. Letters containing only Cyrillic letters are not received.

    Yes, thanks, I'm 100% sure that the problem is with the hosting. I'm moving!

    I did it according to method number 1, but unfortunately the messages do not come, what's the problem?

    Nikita replies:
    07/14/2015 at 22:05

    I did it according to the second method, it works, but only one mail, I try others - nothing comes.

    Indicate which email sites it does not accept and show how you filled in line 56

    $ address = " [email protected]";

    Does the redirect occur after the message has been sent?

    Nikita replies:
    07/15/2015 at 00:29

    yes redirection to the site occurs,

    $ address = " [email protected]";

    I put my mail

    Thank you for the article! helped a lot

    How to add or even transform the code to look:
    First name, last name, patronymic .. and so on .. that is, additional fields are needed

    Good evening, Stepan! Your code is really working, thank you so much for your work! Tell me please:
    1) what command in the php file can set a required or optional field? (now all fields are required)
    2) How can you add a new field exactly in the php file? (in html everything is clear how to do it).

    Hello Stepan!
    I am using the second version of your code.
    The message did not come to mail.ru mail. The message came to Yandex mail instantly.

    What could be the catch?
    In general, thanks, it works. In principle, you can redirect to mail.ru from Yandex ...

    Hello Boris! Have you looked at SPAM on the mail "mail.ru"? Maybe the letter got there

    Boris replies:
    07/30/2015 at 10:33

    Watched. In general, there is some kind of strangeness: letters arrive with a long delay, and not all. Roughly speaking - every other time. In general, there is no logic. Perhaps the hosting is stupid.

    Not possible, but for sure. What kind of hosting? I'll read about them.

    Boris replies:
    08/03/2015 at 10:25

    Skyhost.ru
    For the last year or two, they began to think for a long time, technical support for a long time and often off topic. But price-quality)

    Hello. I can't get the feedback form (((Why - I don't know

    That's what those answered me. support
    The problem with sending letters arises due to the fact that the mail.ru service has blocked the receipt of mail from the server where your account is located. We are working on solving this problem, but, unfortunately, the answer from mail.ru has not yet been received. Mail sending will resume shortly. We are sorry for the inconvenience caused.

    As a result, I scored on mail.ru and sent letters to Yandex.
    But Yandex for some reason sends them to spam.
    In short, they all do not want to work normally

    Good day!
    Raised the local site to openserver.
    I took your form, your script, tweaked it a bit. I send the message to yandex mail.
    What is passed through the inputs turns into questions. Stationary text is displayed correctly.
    I ask for help.

    Your name*


    Date of consultation *


    Consultation time *


    Hello Maxim! I think the problem is in the encoding. The file with the form processor must be saved in UTF-8 without bom. Look

    Maxim answers:
    09/04/2015 at 18:20

    Stepan, thanks. Unfortunately, it didn't help. Likewise, text is displayed with questions.

    Stepan,
    After your advice, the problem was not resolved.
    I ask for recommendations on how to proceed?
    Could there be a problem with Yandex.Mail?

    The problem is 105% encoding. It may be that the server only gives win-1251. Determine what encoding the server is issuing and convert from the one that is issued to the one that is needed on the page. That's all!

    Maxim answers:
    09/21/2015 at 11:52

    Stepan, good afternoon!

    Received a response from Yandex.Mail developers.

    “We checked the letter - no indication of any encoding was found in it. Please check the settings of your form. It does not seem to form a “Content type” header and therefore does not convey any encoding information. ”

    I will sit and figure out why the information is not being transmitted. As soon as I figure it out, I'll write it down in the comments, suddenly someone will have the same problems

    Maxim answers:
    09/23/2015 at 15:37

    After the next iteration, everything worked. Apparently, there were problems with hands and encoding. Thank you, Stepan, for your patience and for such a convenient functionality!

    Stepan, good afternoon.
    Thanks for the form, works well.
    The question arose, how to organize the sending of a letter with a file attachment in option 1 of the form?

    Hello Vyacheslav! Have you tried looking for an answer on sites? There are a lot of solutions on the net how to send a letter with an attached file.
    If you want, I can personally develop php code for you, with the help of which you can receive letters with an attached file to the mail, but it will cost you money.

    Vyacheslav answers:
    09/16/2015 at 20:50

    I found many solutions, but trying to combine them with your form, nothing happened.
    I was able to organize the file selection.
    But to register php directly in the file, there is not enough knowledge of the codes.
    Of course, you can pay money, but I will do it to the person who will make the entire website for me. In the meantime, for a couple of site pages to work, I just need a feedback form.
    Well, since you are such a busy person and cannot suggest a couple of lines of code, thanks at least for the form.

    Stepan, thanks for the simple and working form!
    With Denver, it took longer to figure out than to integrate the form into the page, put the makeup on and launch it.
    Not knowing php at all - I inserted it and it worked!

    Kind time of the day, the code is working and very helpful, thank you very much.
    I wanted to ask a question, is it possible to add a variant on error so that it does not redirect to the main page, but asks to correct the error or redirects to another page.

    Many thanks,

    I inserted a feedback form according to your descriptions, but later abandoned it. But you ruined the page of the site for me. Your page is constantly opening, after 6 seconds, and I can’t do anything, even when I completely deleted your this form arr. communication. Is it a VIRUS !?

    I am looking for how to make a script for a one-page product with an upsell. You have the most

    a sensible explanation of how to send messages to the mail. But I need:
    1. We send to [mail hidden]
    2. We read data from the fields of the Name and Phone form
    3. When you click the "Submit" button on the form, it transfers to an additional

    upsell.php page. BUT AT THIS DATA WITH THE FORM FIELD WILL NOT BE SENT TO E-MAIL,

    ARE SAVING-WAITING FOR SENDING COMMANDS !!!
    4. There are 2 buttons on the upsell page (there is no form):
    a) if the buyer presses the button “Add to the parcel”, then the function comes into play

    sending a mail message with the collected data from the form fields and adding a title

    e-mail
    Name:
    Telephone:
    The name of the additional item.
    b) if the buyer clicks the "Refuse" button, then the sending function comes into play

    mail messages with the collected data from the form fields, but already without adding

    additional product. This is all expressed in the end in the form of a message on

    e-mail
    Name:
    Telephone:

    Good evening Stepan!
    I insert your form into the site, everything is written that the letter is gone!
    But the letter does not come to the post office!
    Please help me figure it out!
    I tried both options, but both forms are processed but the letters do not reach!

    

    Order form.

    Name *

    Email *

    Phone *

    Message:

    Hello Denis! Everything is correct with you. Should work, I even double-checked on my local server. See if letters come in SPAM ?!

    Hello!
    How to add a download of a file to your form, which is located in the root of the site?

    Good day Stepan, on his website I installed your feedback form (FORM 2) after sending writes The message was sent successfully. But nothing comes to the post office. Tell me how to fix it, thanks in advance.

    Hello, using your form as an example, I'm making my own. Please tell me, there are required fields to fill in, but there are optional fields. How to make optional ones? if you do not fill it in, it says “You have not filled in all the fields, go back and fill in the required fields!”;
    In my form, let's say you can attach a picture, but this is not necessary, and in general, the picture will come to the mail or not ???

    I would love to, but there should be a check and a message like “message sent in 6 seconds you will be redirected” should also be what's the matter I don't know look at the pliz code?

    And plus to everything the error 1,3,5,6 is flying out an indefinite form ???

    And he constantly writes “You have not filled in all the fields, go back and fill in the required fields! ”Although I fill in every single one ???

    Stepan I'm waiting)

    Everything worked out for me. I wrote this numbering here in my php file. And about the 11th line, I immediately realized that it is for mandatory filling forms. But the whole thing turned out

    ($ name = $ _POST ["adres"] ($ email = $ _POST ["name"]

    variables are not correct.)
    And instead of sitting, I read a big book by Dmitry Koterov, Alexey Kostarev PHP 5.
    Thank you for your advice

    Can I pay how much will the php registration form cost with a personal account for each user and a payment order in it?

    Good day, Stepan again, tell me why when I create a file with the php extension in the root folder of the site when requested: the site address / php file gives
    Not found

    The requested URL /cgi-bin/php4.fcgi/kontakt.php was not found on this server.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
    the file is created and is located in the root folder. How to fix? Thanks in advance.

    Hello!
    When sending a message, it gives an error - "500: Failed to complete the request due to an internal error on the server."
    What could be the problem?

    I did it according to the second option, it works! Thanks!)

    Hello Stepan!
    I'm running your feedback forms at 3 pm. Option 1 is zero. 2-the message leaves but does not reach the mailbox. The site is on a free host with PHP support. Can you help me figure it out. I'm not looking for ready-made solutions. Best regards. waiting for an answer

    Hello Vadim!
    Have you replaced email?

    $ address = " [email protected]";

    Vadim answers:
    07/17/2016 at 02:17

    Hello Stepan again. Yes. I double-checked everything. Both options work. But it doesn't reach the box. Most likely, the problem is in free hosting. For clarification, I can send the codes and site data. Since this site is a kind of training ground, and I am a person with little experience in this matter (for now). solution. is it worth the tinkering?

    The letter should come to your computer (Disk of the local server / tmp /! Sendmail)

    Vadim answers:
    07/23/2016 at 02:39

    An excellent solution to the question, but I didn’t take this option into account right away. thanks for your responsiveness

    Writes Error, message was not sent!

    Lilia, I checked my shape again, everything works. Look in the handler, somewhere there is some variable that is not correctly spelled out or not at all.

    Alena answers:
    09/26/2016 at 12:03

    Hello! I tried form number 2, everything worked, but letters came only from Yandex mail, or if the krakazyabry just write instead of the address, they don't get through the mail. I also added the line "Phone" and messed it up somewhere, now it doesn't send at all look pliz

    Hello Stepan. Did you accidentally find out the solution from mail.ru, why doesn't it work? I just tried it on hosting, on a subdomain of my site, to test both forms. Everything works well with Google and Yandex mail, but Mail.ru does not get through, the letters do not reach, although the sending is in progress. And it is interesting that it does not work as if you specify the mail of the soap $ address. So even if just in the form, the sender leaves mail on the soap, and in $ address there will be Yandex mail, for example.

    Can not understand. as well as what it did not fix, the server sends an error 405 “Method Not Allowed” when sending a request

    The requested method POST is not allowed for the URL /mail.php.

    how can this be overcome? Thanks!

    Thank you, Stepan! The problem was as you said in the server. Fixed. Now another joke: all the fields are filled in, displays messages that everything was successfully sent, but then instead of redirecting to the main site, displays the message “You have not filled in all the fields, go back and fill in the required fields!”

    In general, Stepan, you are a great fellow! Thank you for your blog, you write very interesting things in an accessible language.

    And to you, Dmitry, thank you for the nice words.
    Write down in the comments what you have done and in which files. In general, everything related to the form.
    Insert the code in the comments via.
    I'll take a look.

    Dmitry replies:
    10/02/2016 at 11:55

    Stepan, in general, was poking around for a couple of days, I can’t finish it))) I realized that the problem was that I added the fields. I registered the fields in the handler. But there is clearly a problem somewhere in my dna, since I do not see the source of the problem. Here is the code from the handler:

    Here is the html code:

    Your name (in full)

    Email

    Phone number

    Region of residence

    Vehicle model

    An initial fee

    Dmitry replies:
    10/02/2016 at 12:04

    found an error in line 4, name instead of fio, fixed it, but did not help

    In line # 8-# 9 you have an error:

    If (isset ($ _ POST ["model"])) ($ body = $ _POST ["model"]; if ($ model == "") (unset ($ model);)) if (isset ($ _ POST [ "vznos"])) ($ body = $ _POST ["vznos"]; if ($ vznos == "") (unset ($ vznos);))

    you need like this:

    If (isset ($ _ POST ["model"])) ($ model = $ _POST ["model"]; if ($ model == "") (unset ($ model);)) if (isset ($ _ POST [ "vznos"])) ($ model = $ _POST ["vznos"]; if ($ vznos == "") (unset ($ vznos);))

    Dmitry replies:
    09.10.2016 at 22:40

    Stepan, you are a genius. Thanks for the tip! Everything worked out

    Hello Stepan and everyone discussing. Thank you for the contact form. I want to share the solution to the problem with addresses with mail.ru.
    in the handler file (mail.php by default) you need to change in the line:

    $ send = mail ($ address, $ sub, $ mes, "Content-type: text / plain; charset = UTF-8 \ r \ nFrom: $ email");

    meaning

    NFrom: $ email

    change to

    NFrom: [email protected]

    not mail.ru only. And letters will go from this address, and not from the one indicated by the sender, including from mail.ru. In this case, the body of the letter will contain the address that the sender filled out in the form.

    hello, I made a form, like everything according to the example, laid it out in Denver, it gives such an error

    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE in Z: \ home \ 192.168.1.227 \ www \ php \ contact-form.php on line 32

    tell me what this means?

    \ r \ n Reply-To: $ email \ r \ n "; if (mail ($ address, $ sub, $ mes, $ from)) (header (); echo" Email sent ";) else (header (" Refresh: 5; URL = https: //hot-potato.studio "); echo" The email was not sent, in 5 seconds you will be back to the main page;)) exit; / * Quit without a message if the bezspama field is filled with something * /?>

    Hello!
    Error in line 32 "Z: \ home \ 192.168.1.227 \ www \ php \ contact-form.php on line 32"

    Echo "The letter was not sent, in 5 seconds you will be returned to the main page;)

    does not precede ";" single quote "‘ ", like this:

    Echo "The letter was not sent, in 5 seconds you will be returned to the main page";)

    try it.

    ro replies:
    06.10.2016 at 23:37

    Hello again. now he found another error in the empty header on line 28, filled it in, and now this one (((
    I can't figure it out in php yet (((

    Warning: Cannot modify header information - headers already sent by (output started at Z: \ home \ 192.168.1.227 \ www \ php \ contact-form.php: 1) in Z: \ home \ 192.168.1.227 \ www \ php \ contact-form.php on line 28

    translated the php file into utf-8 without bom, began to show it without vorning, but the hieroglyphs (((

    and it seems that this is not scary, for some reason the specified letter does not come to the mail

    \ r \ n Reply-To: $ email \ r \ n "; if (mail ($ address, $ sub, $ mes, $ from)) (header (" Refresh: 5; URL = https: // hot-potato .studio "); echo" Email sent ";) else (header (" Refresh: 5; URL = https: //hot-potato.studio "); echo" Email not sent, in 5 seconds you will be returned to the main page "; )) exit; / * Exit without a message if the bezspama field is filled with something * /?>

    ro replies:
    07.10.2016 at 00:00

    it seems that he figured out the encoding, and he writes the letter sent, but it does not come to the mail ((

    For comment line 28

    // header ("Refresh: 5; URL = https: //hot-potato.studio");

    The result has not changed?

    ro replies:
    11.10.2016 at 21:22

    figured it out, comes, but krakozyabry in the mail (((
    it turns out it is necessary to play with the encoding?

    ro replies:
    11.10.2016 at 21:38

    I don't understand at all! everywhere there is the same utf-8 encoding, but all the same comes this one! How to fix it? if I put it without bom, then these hieroglyphs appear on my site. X-Sendmail-Cmdline: sendmail.pl -t -i
    To: [email protected]
    Subject: РЎРѕРѕР ± С ‰ ение СЃ hot-potato.studio
    X-PHP-Originating-Script: 0: contact-form.php
    From: Р РѕРґРёРѕРЅ РњР ° Р »СЊС † ев
    Reply-To: [email protected]

    РЎРѕРѕР ± С ‰ ение СЃ СЃР ° йтР° Hot-potato.studio

    Р˜РјСЏ отпрР° витеР"СЏ: Р РѕРґРёРѕРЅ РњР ° Р" СЊС † ев
    РР "ектроРРЅС‹ Р№ Р ° дрес отпрР° витеР"СЏ: хххххххххххх@gmail.com
    ТеР"РµС" РѕРЅ отпрР° витеР"СЏ: + 7964ххххххххх
    РўРµРєСЃС ‚СЃРѕРѕР ± С ‰ ения:
    РїСЂР ° СЂР ° СЂР ° СЂР ° СЂР °

    ro replies:
    11.10.2016 at 22:37

    I transferred everything to ANSI and everything worked, why is that? and is it okay to use ANSI?

    Stepan, hello!

    In the comments to this topic, I read that you wanted to add a captcha to the code.
    Haven't you done it yet?
    If you did, tell me where you can see it?

    Uppssssss! Alexander, didn't.
    It will be necessary to correct and tighten this issue

    Alexander answers:
    12/04/2016 at 12:21

    Stepan, hello!
    And you have not yet sent the captcha?

    It is easier for me to use ready-made solutions with wide functionality, for example the form builder testograf.ru
    Huge selection of field types + the ability to download a file. Also all this is free!
    Read more about how to create a feedback form here: testograf.ru/ru/blog/forma-obratnoj-svyazi.html

    Good afternoon, Stepan, I tried option 1, everything works, but when a letter arrives instead of Russian and Lithuanian letters, hooks, tried options with encodings, it did not help.

    Good day! To be honest, I didn't understand. I made a php site, but how to insert a form on the right page in the right place?

    Hello! inserted a form according to Method-1, all the time he writes "You have not filled in all the fields, go back and fill in the required fields!" although they are all filled. please tell me what could be the reason

    handler code:

    Hello!
    The code is not written correctly.
    The form does not contain “name =” NAME ”, name =” EMAIL ””, etc.

    Tim replies:
    06.12.2016 at 12:33

    Good day!
    I inserted the form on the page, thanks.
    But it does not work - the letters do not reach, I suspect that the path to the mail.hp files was not indicated correctly
    And, most importantly, when you send a message, it pops up that the message has been sent and after 6 seconds you will be redirected to the website
    Stepan, how to remove it? Where can I change the entry?

    Oh, I corrected the message.)
    But how to write the path to the files correctly?
    If the mail.php file is located in the same folder, public html, where all the pages of the site are, does this mean that you need to specify the path as to the page site.ru / mail.hph?
    Thanks in advance!

    Stepan! It all worked! This message does not reach when I try to send from my own address to myself, and from other addresses, or if I just specify 123 instead of the address, they get it.
    Sorry to bother you!
    And THANKS again!

    Dear Stepan!
    I ask you to help, otherwise I will go crazy. It's not the first day I've been struggling with sending mail from the site. Two files: mail.php and contacts.html Both files are in utf-8. The site itself on the ISP hosting is also in utf-8.
    Problem: letters come to the box, but in finches in this form -

    Р˜РјСЏ РїРѕСЃР »Р ° РІС € его: Р˜РіРѕСС РР» РµРєС‚СЂРѕРЅРЅС ‹Р№ Р ° РґСЂРµС: [email protected]КонтР° РєС‚РЅС ‹Р№ тел РµС „РѕРЅ: 1111111111 РЎРѕРѕР ± С ‰ ение: ПроверкР° СЃ СЃР ° йтР°

    In Notepad converted (although before conversion it was like this

    Sender's name: Р˜РіРѕСЂС Email address: [email protected] Message: РџР РћР'Р Р РљРђ

    Here is the mail.php code

    Name not specified!

    "; echo" Return to filling out the form"; exit;) else if (empty ($ email)) (echo" Email not specified!

    "; echo" Return to filling out the form"; exit;) else if (empty ($ mess)) (echo" Message not written!

    "; echo" Return to filling out the form"; exit;) else $ to =" [email protected]"; / * SPECIFY YOUR ADDRESS! * / $ Charset =" UTF-8 "; $ subject =" Message from your site "; $ message =" Sender's name: $ name \ nEmail address: $ email \ nContact phone: $ phone \ nMessage: $ mess "; $ send = mail ($ to, $ subject, $ message); if ($ send ==" true ") (echo" Thanks for sending your message!

    "; echo" Click, to return to the main page ";) else (echo"

    Error. Message not sent! ";)?>

    Mail is sent from ******* / contacts.html page

    Changed the mailbox to @ ukr.net; otherwise, to @rambler, emails went to spam.

    Can you figure it out? Thanks for the answer.

    While I was waiting and did not wait for an answer, I did everything myself. It works. The reason was very interesting.
    I would like to see the work on the creation of sites, the author of the blog, I did not see links to them.

    And tell me, please, how to center this wonderful shape horizontally. So that it is displayed in the center of the page. And at the same time, the left side was aligned as it is now.

    Are there any options other than wrapping the div, centering it, and aligning the content to the left?

    Yes, this option, the only one, came to mind, but my hands have not yet reached, the New Year is on the nose, after all, and the skills of web-programming are frankly not enough to easily and naturally align the form.

    Thanks! And happy New Year!

    Good time! How to make sure that for a client instead of a mail for feedback there is only a phone number? Thanks!

    Hello Stepan! Help me please. For the second week I have been making a feedback form, tried an infinite number of forms, and today I finally managed to get the form to return the answer: Your message has been sent. and it was exactly your form. However, only those letters in which as an e-mail are sent via it. addresses the site visitor did not specify a mailbox on mail.ru. The hosting wrote to me in response to my complaint, why emails do not come, this is the answer:
    Probably, the form on the site substitutes the address specified in the “Email *” field as the sender.

    In this case, problems may arise if the user specifies any mailbox on mail.ru. In this case, we recommend setting the address based on your domain as the sender's address. Adjusted the txt spf record for this to allow sending from the hosting server for the given domain:
    v = spf1 ip4: 37.140.192.244 a mx include: _spf.mail.ru ~ all

    How can I replace the address in mail.php?
    I tried replacing line # 5:

    If (isset ($ _ POST ["email"])) ($ email = $ _POST ["email"]; if ($ email == " [email protected]") (unset ($ email);))

    e-mail address based on my domain - it is also generated on mail.ru, but that's not the point if you insert the address there on

    [email protected]

    - the letter will not come either.
    Maybe you can tell me how to set the address based on my domain as the sender's address.

    Hello Stepan! I reread all the comments and found the answer to my question, fixed everything, everything works! thanks a lot! Can you tell me more, please, is there any way to create a mask for the $ etel field with a phone number, so that if the user did not enter the phone number in full, the form would indicate it to him?

    Hello Ekaterina.
    What was the reason?
    For a field with a phone, you can create a simple tooltip using HTML5.
    Here's a look at the possibilities for the form.

    Ekaterina replies:
    03/14/2017 at 05:32

    Good day! The reason is probably hosting (I have reg.ru). They, apparently, have some problems with sending letters from mail.ru boxes through the site. They configured me so that emails sent from mail based on the domain name would arrive without problems, and I changed line 15 of the form:

    $ send = mail ($ address, $ etel, $ mes, "Content-type: text / plain; charset = UTF-8 \ r \ nFrom: $ address");

    and now letters come from my mailbox to my mailbox, and the content is what the site visitor will indicate.

    Stepan, hello! I used the first option for placing the form and encountered the following error when pressing the submit button: Parse error: syntax error, unexpected T_NS_SEPARATOR in /var/www/vhosts/***.plsk.regruhosting.ru/httpdocs/***. ru / mail.php on line 13
    The code in the handler:

    Code in page:

    Write to us or order a call back!

    Your name

    Email

    Phone number

    Call you back?

    Message text:

    Judging by the text of the error, I understand that I have mishandled the symbols in the handler somewhere, but I can't find it - I broke my eyes ... Would you suggest an idea? Thanks in advance!

    Sergey answers:
    03/05/2017 at 21:05

    Found extra quotes, the error disappeared. But now there is another problem ... The letter arrives, everything is displayed normally, but the fields seem to be empty. That is, as if the handler does not pick up data from the html form.
    php converted like this:

    Implemented filling check via html:

    Your name

    Email

    Phone number

    Call you back?

    Would you like to receive an electronic catalog?

    Message text:

    If the check for mandatory filling is returned to php, then a message is displayed as if not a single line in the form has been filled. That is, in both cases, the handler does not seem to "see" the filling on the page. I repeat, it comes, it is displayed correctly, there are “profiles” categories, but they are empty. Where to look here? Tell)

    I didn’t find line 9 in your code.

    If (isset ($ name) && isset ($ email) && isset ($ sub) && isset ($ ring) && isset ($ catal) && isset ($ body)) (

    Add the following code to the handler:

    Print_r ($ _ POST)

    Rewrite and send me what you see on the screen.

    Sergey answers:
    03/06/2017 at 15:08

    And where exactly should you add to the logical chain?

    Print_r ($ _ POST)

    Which line?
    Thank you again for your attention!

    Good afternoon, Stepan! Thank you so much for the article) I did everything according to the 1st option - the form works, but when I paste your code for decorating the form in style.css, nothing changes ((The form is working, but completely nondescript ((
    Help me please!

    Hi, I'm writing a diploma here and decided to insert a return line, but without hosting, as I understand it, it can't be done? For some reason, your method does not work, or I messed up with the paths (

    Thanks! however does not work. and it worked once. how can this be

    yeah. works if everything is written in Latin. if in Cyrillic then either does not come or question marks. if I specify a return mail from gmail, then the letter goes through, if from mail.ru - then it does not go through. how can this even be?

    the second method works completely, but if you specify the sender's address on the mail ru (list.ru ets), then the letter does not come
    with qip.ru nm.ru letters go through normally. from rambler too. mailbox and its domains are blocked somewhere.

    Hello Stepan!
    I used form 1. I made changes for my site, but for some reason the letters do not come to the mail. You could see if I messed something up?
    I would be grateful for your answer.

    Good afternoon, Stepan!
    Out of 2 of your topics (the present and the topic of feedback with captcha, I tried to compose one feedback form for myself. Letters come to the mail, from this side everything is fine. The question is that there is no transition to the main page of the site. An empty one appears the page with the caption. The record set in the php file hangs for 5 seconds, then there is a record that not all the fields are filled (although all the fields are filled in.) But you can see that every 5 seconds the page tries to refresh. Please help with this error.

    Hello, please tell me, after pasting the code, this part is displayed in text on the page:

    Could it be that Word press does not see this part of the code?

    Good afternoon.
    Stepan, thank you very much. It all worked!
    Can you clarify: how can you correct the code so that after sending a message, the user goes to the page from which he sent the message (i.e. to the previous one), and not to the main page?

    Thanks in advance.

    Website address, where you can continue your browsing ";) else (echo" The message was not sent! ";)) else (echo" You did not enter the numbers from the picture correctly ";)) else (echo" You did not fill in all the fields! ";)? >

    Good day Stepan) Question how to connect the definition of the sender's ip, added a field

    If (isset ($ _ POST ["ip"])) ($ ip = $ _POST ["ip"]; if ($ ip == "") (unset ($ ip);))

    not displayed, thanks in advance.

    Good afternoon.
    I tried to add a feedback form to the site and ran into a problem that the form seemed to be working properly, but no messages were received by mail. In the end, I took a clean form from the second method and corrected the mail line in it to my mail. What could be the problem? The hosting is paid and supports php scripts. The PHP version is 7.0.

    Hello, Alexander!
    If, after submitting the form, you see the message “Message sent successfully. Go to the main blog page ... ”, it means that the form was submitted successfully.
    Why are there no letters in the mail in the inbox?
    1. Line 54 - $ address = “ [email protected]”; correct to your mail.
    2.See if the emails got into SPAM

    Alexander answers:
    06.12.2017 at 09:23

    Line 54 corrected to my mail. There is nothing in the spam mailbox either. Maybe you need to write to the hosting tech support, but I don’t know what to write?

    try here.
    You can catch the php handler from there and write it under your form.

    Alexander answers:
    06.12.2017 at 20:25

    And this form also works and does not give errors, but letters do not come to the mail. I changed my mail in it. Apparently even though the hosting supports php, you need to enable something in the settings, and what exactly I do not know.
    Hosting is used by nic.ru Tariff 200
    I wrote to technical support, but they are silent.

    A question. In the form there is where to register to which postal address to send letters, but where do you need to register from which mailbox to send letters? Or should the hosting itself be understood by default?

    Technical support replied that the mail function on the hosting is working properly. Gave a script to check
    A letter from the hosting came to the mail. They said to check the forms again.

    Good afternoon, Stepan! Installed your feedback script in the first way, everything works. Thanks! Not good at programming. Tell me what to add to the mail.php code so that the message about sending the message is reflected in a small pop-up window. Thanks again!
    Yes, I also tried the script with captcha, but for some reason the numbers are not displayed. GIFs and files in their places.

    Hello Igor!
    Item number 15 in the code:

    (echo "The message was sent successfully, after 6 seconds you will be directed to the main page of the blog site, where you can continue your browsing";)

    add a CSS class with styles to the message and that's it (you can do this):

    (echo "

    The message was sent successfully, after 6 seconds you will be directed to the main page of the blog site, where you can continue your browsing

    ";}

    if (isset ($ _ POST [‘name’])) ($ name = $ _POST [’name’]; if ($ name == ”) (unset ($ name);))
    Can you explain what is written in this line, what is being checked?

    Hello. But how to send a form if I have a site on a local server? Using Open Server

Greetings to my readers, I have gained experience and I will tell you about the principles of the php feedback form. I'll show you with illustrative examples so that you understand how everything works and how the interaction between the input form itself (its input fields) and the handler file written in php takes place. In addition, you can download the sources for free along with.

Of course, it will be great if you know a little about HTML / CSS. By analogy, you will have to drag the code onto your page. We will not touch on the PHP language, I will show all the necessary edits that need to be done for myself.

UPDATE: According to the responses of readers, I realized that you need something more beautiful and functional, meet, read and see. Choose which one you like best)

UPDATE2: Version 3.0 Responsive Landing Page + ajax form with passing UTM tags, read and see. You'll like it

I remembered myself when I first tried to make my own feedback form in php, and to be honest, it was laborious, because did not understand what was happening and how. Patience and perseverance are friends and you will succeed.

Php contact form - structure

We will study the analysis of the feedback form itself on the example of a landing page (Landing Page), by the way, there is a separate article on. You can see how it works in action using the buttons below, I attach the sources of this one-page page and the main file of the php handler (this file will process and send a letter to email)

After downloading the sources and unpacking the archive, you will see the following file structure:

  • image - all images that are used for the Landing Page itself, buttons, etc.
  • js - javascript scripts that provide, for example, a popup modal on the page and other visual effects
  • index.html - our one page index file
  • index1.php - a handler file into which values ​​from the form are passed, then a letter is formed from the received variables and sent to the specified email address. Also, index1.php will act as an intermediate page for notification of successful data submission with automatic redirection back to index.html (i.e. our one-page page)

It is important that your hosting, on which the site files are located, supports php processing, otherwise the index1.php file will not be executed and will not work. To clarify this nuance, contact the campaign where your hosting is registered or just test it - it works, which means there is support. If not, then enable php language support option

Take a look at how the interaction of all elements (page, form, handler) works

The source code of the form call and handler

Let's take a look at the operation of one of the buttons, which invokes a modal pop-up window that contains a feedback form. This given source code is more than once, two inserted into the page and it will work, you yourself will have to customize it to your design and needs.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Request a call back

Request a call back

Below is the full source code of the index1.php handler, in order to configure sending to your mailbox, change “ [email protected]»On your own, the rest, in principle, can be left unchanged

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 "; // from whom $ send = mail ($ address, $ sub, $ mes," Content-type: text / plain; charset = utf-8 \ r \ nFrom: $ email "); ini_set (" short_open_tag ", "On"); header ("Refresh: 3; URL = index.html");?> You will be contacted

Attention! Fast order service is available only for residents of Moscow. This is due to the fact that more detailed information is required for residents of other cities.

Order glasses and frames quickly on StarOptic

Please register on the website to make purchases in our online store.

Register now

The next step is to see if the order has been shipped. If yes, then we display a message about successful sending.

Order glasses and frames quickly on StarOptic

size ("contact")> 0) (echo $ messageStack-> output ("contact");) // if the order has been sent, we display a message about successful sending if (isset ($ HTTP_GET_VARS ["action"]) && ($ HTTP_GET_VARS ["action"] == "success")) (?>

The order has been successfully sent to the store's service department. Our manager will contact you by contact phone to clarify the details of the order and delivery time.

Otherwise, we display the quick order form:

Else (// otherwise (if the order has not been sent yet) display the quick order form:?>

"; ?> ". $ products_price." ". $ product_info [" products_name "]." " . "
Delivery: Delivery within Moscow within the Moscow Ring Road (for orders over 3500 rubles) free of charge. Read more about delivery terms here ");?> ">">
Your name:
Your phone number:
Address in Moscow:
Message:

The quick order script is now complete.

Calling the quick order window on the product page

On the product page, we prescribe a call to the quick order window. To do this, we need to create a second “Quick order” button next to the “Add to cart” button and generate a link of the form: http: // [online store] /bistriy_zakaz_s_sayta.php?products_id=.

"> Quick order

Using a similar scheme, you should create buttons for quick ordering of goods on category pages.

Top related articles