Html uses form tags to interact with users and form tags
Use Form tags to interact with users
How does a website interact with users? The answer is to use an HTML form (form ). A form can transmit the data input by the viewer to the server, so that the server program can process the data transmitted from the form.
Syntax:
<Form method = "Transfer method" action = "Server File">
Explanation:
1.<Form>:<Form> tags appear in pairs, starting with <form> and ending with </form>.
2.Action :The place where the data input by the viewer is sent, such as a PHP page (save. php ).
3.Method :Data transmission method (get/post ).
<FormMethod = "post" action = "save. php"> <Label for = "username"> User name: </label> <input type = "text" name = "username"/> <label for = "pass"> password: </label> <input type = "password" name = "pass"/> </form>
Note:
1. All Form Controls (text box, text field, button, single button, check box, etc) must be placed between <form> </form> labels (otherwise, the information entered by the user cannot be submitted to the server !).
The get and post methods in Form correspond to the GET and POST methods respectively during data transmission.
The main differences between the two are as follows:
1. Get adds the data in the form to the URL pointed to by action in the form of variable = value, and the two use "?" And each variable is connected by "&". Post puts the data in the form data body and passes the data to the URL indicated by the action according to the corresponding variables and values.
The format is as follows:
Http://www.imooc.com/test.asp? Name = lilian & password = 12345678
2. Get is insecure because data is stored in the requested URL during transmission, so that some private information may be viewed by a third party.
3. The size of data transmitted in Get mode is very small, generally around 2 kb, but the execution efficiency is better than that of Post method. In Post mode, the amount of data transmitted is relatively large, it is waiting for the server to read data, but there are also byte restrictions. This is to avoid malicious attacks on the server using a large amount of data. According to Microsoft, Microsoft uses Request. the maximum data that Form () can receive is limited. IIS4 is 80 KB, and IIS5 is kb.
To sum up, use the Post method whenever possible.