How To Insert A Form On A Website

Table of contents:

How To Insert A Form On A Website
How To Insert A Form On A Website

Video: How To Insert A Form On A Website

Video: How To Insert A Form On A Website
Video: 🟣How to add a form to your website - in 5 min 2024, November
Anonim

Forms on the site contain various controls and are used to organize user interaction. The presence on the site of the form allows the user to enter and send registration data, messages and other information. Moreover, the form should not only read the entered text, but also process it in a certain way.

How to insert a form on a website
How to insert a form on a website

It is necessary

form script

Instructions

Step 1

The main difficulty in creating a form is to ensure the security of the information entered for the site and other users. One of the most common vulnerabilities is the so-called XSS injection, the essence of which is the possibility of executing malicious executable code in the user's browser. Therefore, the form must have a filter that does not allow entering dangerous characters or replaces them with safe counterparts in a different encoding. Filters are also needed in other situations - for example, in the field for entering an e-mail address, there can be a filter for entering characters in any layout, except for English.

Step 2

The form is implemented in a script written in one of the scripting languages, most often PHP is used. The form code can be inserted into the site in two ways: directly into the page code and in a separate attached file. In the first case, the executable code is enclosed between tags (without quotes). The page extension must be *.php. If the page has a *.html or *.htm extension, you just need to change it to *.php. The server can be configured to process php files with different extensions; in this case, there is no need to change the extension.

Step 3

If the script is presented as a separate file, a corresponding link of the form should be made to it in the page code:. If the pages on your site have the *.html extension, then change it to *.php or create a.htaccess file in the site root (with a period in front of the name), then add the line "AddHandler application / x-httpd-php.html.htm "(without quotes).

Step 4

You can write the form script yourself, but it is much easier to find a ready-made version on the Internet and modify it as needed. It is best to look at the code of several options, evaluate their advantages and disadvantages. Once you understand how the form script is built, you can always change it the way you like, or create your own based on the pattern of existing scripts.

Recommended: