亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

HTML基礎(chǔ)教程之GET方法和POST方法

GET方法和POST方法


GET提交方式(很少用到)

GET方式,是將表單數(shù)據(jù)追加到action指定的處理程序的后面,然后向服務(wù)器發(fā)出請求。

注意:地址欄傳數(shù)據(jù)的方式,默認(rèn)就是GET方式。

還是來改造我們的第一個例子

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>用戶注冊</title>
    </head>
    <body>
        <font size="5" color="red">歡迎注冊php.cn</font>
        <form name="user" method="get" action="" >
            用戶名:<input type="text" name="username"/>
            <br/>
            密碼:<input type="password" name="userpwd"/>
            <br/>
            <input type="submit" value="提交信息"/>
        </form>
    </body>
</html>

在本地測試時,填寫了信息,然后點擊提交之后,可以觀察到瀏覽器地址欄變成

15.png

上面URL的說明:

  • login.php  //是表單處理程序文件

  •  username=小明&userpwd=123456 //表單提交的數(shù)據(jù),又稱為“查詢字符串”。

  •  action文件和查詢字符串之間用“?”分隔。

  •  每兩個表單元素的“名稱=值”之間用“&”分隔。

  • 表單名稱和表單值之間用“=”分隔。

注:如果某個表單元素,不想往服務(wù)器傳遞數(shù)據(jù),那么,我們可以不給它加name屬性。傳遞到服務(wù)器的數(shù)據(jù),如果沒有name,則無法獲取它的值。

GET方式的特點:

  •  GET方式不能提交敏感數(shù)據(jù),如:密碼。

  •  GET方式只提交少量數(shù)據(jù)。因為地址欄的長度有限制,大約100外字符。

  •  GET方式下不能上傳附件。


POST表單提交方式

POST提交方式,它不是將表單數(shù)據(jù)追加到地址上,而是直接傳給表單處理程序。

POST方式的特點:

  •  POST提交的數(shù)據(jù)相對安全。

  •  POST可以提交海量數(shù)據(jù)。

  •  POST方式可以上傳附件。

來看一個實例:

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>用戶注冊</title>
    </head>
    <body>
        <font size="5" color="red">歡迎注冊php.cn</font>
        <form name="user" method="post" action="login.php" >
            用戶名:<input type="text" name="username"/>
            <br/>
            密碼:<input type="password" name="userpwd"/>
            <br/>
            <input type="submit" value="提交信息"/>
        </form>
    </body>
</html>

注:本地測試時,觀察地址欄的變化,看看是否和get提交方式一樣

Weiter lernen
||
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>用戶注冊</title> </head> <body> <font size="5" color="red">歡迎注冊php.cn</font> <form name="user" method="get" action="" > 用戶名:<input type="text" name="username"/> <br/> 密碼:<input type="password" name="userpwd"/> <br/> <input type="submit" value="提交信息"/> </form> </body> </html>
einreichenCode zurücksetzen