How to create a form for sending

How to create a form for sending

Forms are used on web pages for data entry which then go to the server and processed. Enter information for registration into them, the login and the password for an input on the website, send messages. The code of a form is located tags and. The form is created by means of html markup language, and the entered data then are processed by a script in the PHP programming language.

Instruction

1. Write the code of a form for sending the message. Set attributes of the <form> tag. The name attribute is the name of a form, for example, of ""form1"". Having set her name, in the presence of several forms you will be able to contact each of them separately. The action attribute indicates the file of a script processor where these messages after input will be sent, here messages.php will be the file of processing. The method attribute can have ""get"" and ""post"" values (it is used more often) that means respectively the open and hidden sending data. It is a method by which the entered data are sent to the server. The next line turns out: <form name='form1' method='post' action='messages.php'>

2. Add the name of the field of a form: <p> your name: <br>. The tag <p> will set the new paragraph, and <br> will provide transfer of the next line.

3. Add a text box - use the <input> tag and its attributes: type, name, maxlength. The type attribute designates input element type (in this case text - a text box). The name attribute - an element name, for example, ""firstline"". By means of maxlength set maximum the number of signs, for example, 20. Type of a line: <input type='text' name='firstline' maxlength= '20'>

4. Add the name of the field of a form: <p> enter the text of the message: <br>.

5. Create the field for the message. Use the <textarea> tag. Set a name (name) of the field, for example, of ""message"". Specify field height - number of lines (rows) and also field width (number of columns) - cols. The line will look so: <textarea name='message' rows= '6' of cols= '50'> </textarea> </p>

6. At will make the field for the indication of the e-mail address: Your email:
<input type='text' name='email'>

7. Create the button for sending data. Use the <input> tag with attributes. The submit value of the type attribute will provide sending data, the value attribute will set value of the button. The line will turn out: <input type='submit' name='button' value='otpravit'>. The form is ready, now put the closing tag </form>.

8. Add the received code to the file of the web page and browse result in the browser.

9. It was the algorithm of creation of a form of sending the message by means of html. For functioning of mail on the website of it it is not enough. Therefore also create the messages.php file with a script of processing of the sent data, the file should be in one folder with other files of the website. Also register the beginning of a session, etc.

Author: «MirrorInfo» Dream Team


Print