1.8.10- form fields

In HTML, form tags are used to define the form fields that create a form in order to achieve the collection and transmission of user information, all content will be in the form submitted to the server. Create a form of basic syntax is as follows:

< Form Action = "url address" Method, = "submission" name = "form name" >   
    variety of form controls 
</ form >

Common attributes:

  1. Action when the form information is collected, the information needs to be passed to the server for processing, action attribute specifies the address of the server to receive and process program url form data.

  2. method Submit form data for setting a way to get its value or post.

  3. name specifies the name of the form, to distinguish multiple forms of the same page.

Note: Each form should have its own form fields.

 

We learned three domains:

1. text field: textarea comment

2. File field: input type = "file" uploaded files

3. The form fields: from collecting information and submit the form control.

 

 code show as below:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <h3>表单域</h3>
    <form action="">
    <p>用户名: <input type="text"></p>
    <p>&nbsp;码: <input type="text"></p>
    <input type="submit" value="提交"/>
    <input type="submit" value="重置"/>

    </form>
</body>
</html>

Browser opens:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <h3>表单域</h3>
    <form action="www.baidu.com" method="get">
    <p>用户名: <input type="text" name="username"></p>
    <p>&nbsp;  码: <input type="text" name="pwd"></p>
    <input type="submit" value="提交"/>
    <input type="submit" value="重置"/>
    </form>
</body>
</html>

 

 如果是get请求提交信息在URL里面显示:

 

 

 

 get  速度快 但是会在URL里面显示表单提交的内容 不能做密码提交

post 速度慢 但是不会显示表单内容 安全一些。

 

Guess you like

Origin www.cnblogs.com/Chamberlain/p/11202555.html