Forms are used on web pages to enter data, which is then sent to the server and processed. They enter information for registration, login and password to enter the site, send messages. The form code is located with and tags. The form is created using the html markup language, and the entered data is then processed by a script in the php programming language.
Instructions
Step 1
Write the form code to send the message. Set the attributes of the tag. The name attribute is the name of the form, for example "form1". By specifying its name, if you have multiple forms, you can refer to each of them separately. The action attribute points to the handler script file, where the message data will be sent after input, here the processing file will be messages.php. The method attribute can have the values "get" and "post" (used more often), which means, respectively, open and hidden sending data. This is the method by which the entered data is sent to the server. It turns out the following line:
Step 2
Add the name of the form field:
Your name:
… Tag
will set a new paragraph, and
will provide the next line break.
Step 3
Add a text box - use the tag and its attributes: type, name, maxlength. The type attribute denotes the type of the input element (in this case, text is a text field). The name attribute is the name of the element, for example, "firstline". Use maxlength to set the maximum number of characters, for example, 20. String view:
Step 4
Add the name of the form field:
Enter your message text:
Step 5
Create a field for the message itself. Use a tag. Specify a name for the field, for example "message". Specify the field height - the number of rows (rows), as well as the field width (number of columns) - cols. The line will look like this:
Step 6
Optionally, make a field for specifying an email address: Your email:
Step 7
Create a button for submitting data. Use a tag with attributes. The "submit" value of the type attribute will send the data, the value attribute will set the value of the button. The line will turn out:. The form is ready, now add a closing tag
Step 8
Add the resulting code to a web page file and view the result in a browser
Step 9
This was the algorithm for creating a post form using html. This is not enough for the functioning of mail on the site. Therefore, also create a messages.php file with a script for processing the sent data, the file should be located in the same folder with the rest of the site files. Also write down the beginning of the session, etc.