学无先后,达者为师

网站首页 编程语言 正文

初识form表单中的两种提交方式

作者:SSS4362 更新时间: 2022-07-10 编程语言

初识form表单中的两种提交方式

1.get提交

1.1 具体表现形式

表单填写的数据会在地址栏显示

这种方法是极其不安全的,因为造成用户信息的泄露

1.2 源代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>form表单中的两种提交方式</title>
</head>
<body>
    <form action="#" method="get">
       账户:<input type="text" name="username" id="" placeholder="请输入用户名"><br/>
       密码:<input type="password" name="password" id="" placeholder="请输入密码"><br/>
       <input type="submit" value="登录">
    </form>
</body>
</html>

1.3 显示效果

1.3.1 点击登录按钮后

在这里插入图片描述

1.3.2 点击登录按钮后

在这里插入图片描述

2.post提交

2.1 具体表现形式

表单填写的数据不会在地址栏显示

1.2 源代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>form表单中的两种提交方式</title>
</head>
<body>
    <form action="#" method="post">
       账户:<input type="text" name="username" id="" placeholder="请输入用户名"><br/>
       密码:<input type="password" name="password" id="" placeholder="请输入密码"><br/>
       <input type="submit" value="登录">
    </form>
</body>
</html>

1.3 显示效果

1.3.1 点击登录按钮后

在这里插入图片描述

1.3.2 点击登录按钮后

在这里插入图片描述

3.总结

如果method属性不写的话,默认会为get提交方式

区分get提交方式和post提交方式的方法是提交表单后,看表单内容是否在地址栏显示

原文链接:https://blog.csdn.net/SSS4362/article/details/125451841

栏目分类
最近更新