HTML form 表单提交方式get和post的区别

method属性规定如何发送表单的数据。有两种提交的方法分别为get和post。

1、get:提交的数据量要小于1024字节,表单提交时表单域数值(表单请求的信息:账号、密码…)将在地址栏显示。

<!DOCTYPE html>
<html>
<head>
    <title>测试get提交数据方法</title>
</head>
<body>
    <center>
        <form action="https://www.baidu.com" method="get">
            <p>用户名:<input type="text" name="name"/></p>
            <p>密码:<input type="password" name="pwd"/></p>
            <input type="submit" value="登录">

        </form>
    </center>
</body>
</html>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

登录主界面: 
这里写图片描述

跳转页面: 
这里写图片描述

2、post:传递的数据量不受限制,表单提交时表单的域值(表单请求的信息:账号、密码…)不会在地址栏显示,安全性能较高,对信息进行了隐藏,一般在开发中采用post。

<!DOCTYPE html>
<html>
<head>
    <title>测试post提交数据方法</title>
</head>
<body>
    <center>
        <form action="https://www.baidu.com" method="post">
            <p>用户名:<input type="text" name="name"/></p>
            <p>密码:<input type="password" name="pwd"/></p>
            <input type="submit" value="登录">

        </form>
    </center>
</body>
</html>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

登录主界面: 
这里写图片描述

跳转页面: 
这里写图片描述


猜你喜欢

转载自blog.csdn.net/sayesan/article/details/79662858