- A Simple Feedback Form
- An Example Form
- How This Form Works
- The Form Element
- Text Boxes
- Submit Button
- Putting It All Together
- Разметка HMTL
- Стилизация CSS
- Адаптация под мобильную версию
- Исходный код
- Как создать форму обратной связи на сайте
- 1. Создание HTML-структуры
- 2. Стилизация формы с помощью CSS
- 3. Добавление функциональности с помощью JavaScript
- 3 способа. Как сделать форму обратной связи на html?
- Способ №1. Форма обратной связи html + php.
- Способ №2. Сервис для формы обратной связи.
- Способ №3. Ссылка для отправки email.
A Simple Feedback Form
To compel the average web surfer —arguably one of the most demanding individuals on the face of the earth— to click on an email link, wait for their email program to open up, remember how the email program works and then send you an email is, in fact, a formidable task (Oh bother! My email program takes 7.2 seconds to load! You can’t be serious!!)
Hence, as a matter of convenience (and to show everyone that you are above the cut by displaying some advanced web design skills) you might want to create a feedback form that visitors can use to send you an email directly from your contact page. The following is a crash course on how to create such a form.
An Example Form
Below is an example of a simple feedback form. The user types the appropriate information into the three text boxes and then clicks on the «Submit» button to send the data as an email to the designated recipient (you).
How This Form Works
What’s going on behind the scenes can be roughly divided into two parts. The first part is the HTML source code that actually renders this form in a web page. In this source code, each of the three text input boxes is identified by a unique «control name».
The second part of the form is a form mail script (kind of like a little program) that is configured and placed in a special folder in your website’s root directory called cgi-bin. When the user clicks on the Submit button, the form calls the form mail script into action. The form mail script uses the text box control names to collect and organize the information entered into the form and then sends it off as an email.
Most webmasters will only concern themselves with how to render the form using HTML source code and then afterward download and install a ready-made form mail script to process it. There are many free ready-made form mail scripts to be had out there on the internet. If you’re looking for a quality open-source (free) form mail script, I personally recommend NMS FormMail. For more information, please see Installing NMS FormMail.
The Form Element
Okay so let’s deal with the first part of our simple feedback form which is the HTML source code required to create it.
- action ~ The value of the action attribute contains the URL to the script that will process the form (we’ll get to that later. )
- method ~ The value of the method attribute is either GET or POST. You will use one or the other depending on the requirements of the script processing the form. The method most commonly used is POST.
To help with layout and presentation, the
tags may also contain most other HTML elements but, with the exception of
tags, we’ll leave them out for now to keep this tutorial simple.
Text Boxes
- input ~ The input element will create a single-line text box when the type=»text» attribute value pair is used. Only the start tag is used. The end tag is omitted. You will also require a name attribute-value pair where control_name equals the control name (whatever you want) that you assign to this text box. This control name will be used by the script that processes this form to retrieve the data entered into this text box. Each input text box must have a different control name.
So if we insert the following code inside our form element:
. it will render the following result:
- rows Red»>number_of_lines » — This attribute-value pair specifies the height according to the number of text lines you wish the textarea box to display.
- cols Red»>width_in_characters » — This attribute-value pair specifies the width according to the number of character widths you wish textarea box to display.
. it will render the following result:
Submit Button
Now let’s create a submit button that the user can click on to activate our simple feedback form after entering his or her information. Once again we’ll use the input element but this time we’ll insert the type=»submit» attribute-value pair. To customize the text that is displayed on the submit button, you can use the value attribute-value pair where your text can be anything you want. To keep it simple (and polite) we’ll just use the word «Submit». Hence if we insert the following code inside our form element :
. it will render the following result:
Putting It All Together
Alright then, if we take all the HTML source code for our form element, text boxes and submit button and put it all together, the following is what we get:
So all you have to do is whip up an essential web page structure (or use a web page that you’ve already created) and then insert the above source code anywhere in between the
. tags and then presto.You got yourself a simple feedback form.
For the purposes of the next tutorial on installing NMS FormMail, let’s name this feedback form page » contact.htm «.
Next, let’s deal with the second part of our feedback form which is the script that will actually process the form when a user clicks on the Submit button.
If you need a .COM web address, you can get one quick and easy at.
Разметка HMTL
Сначала сделаем разметку нашей будущей формы. В HTML коде я написал подробные комментарии.
Если у вас есть какие-то вопросы или предложения по сотрудничеству - заполните форму ниже