数据的提交与接收-get与post区别

来源:互联网 发布:mysql engine=myisam 编辑:程序博客网 时间:2024/04/29 13:18

提交页面


<!DOCTYPE html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<body>
<form action="jieshou.php" method="get">
<table>
<tr>
<td>请输入名字</td><td><input type="text" name="name"></td>
<td>请输入年龄</td><td><input type="text" name="age"></td>
<td colspan="2"><input type="submit" value="提交"></td>
</tr>
</table>
</form>
</body>


接收页面

<?php

$name=$_GET['name'];
$age=$_GET['age'];
  echo "接收到的名字是:  ".$name."<br/> 接收到的年龄是:  ".$age;


?>


form 表单的提交方式有两种:get  方式提交 和 post 方式提交!

这两种方式的区别有一下几点:

1get 方式提交后刷新和后退不会从新提交! post 方式提交后刷新和后退post数据会从新提交!

2get 书签可以收藏,post书签不可以收藏

3get 历史参数保留在浏览器历史中。 post 参数不会保存在浏览器历史中

4get 对数据长度有限制(最大长度是 2048 个字符); post 则无限制

get的安全性较差 get的数据在 URL 中对所有人都是可见的。 post 的数据不会显示在 URL 中。

在发送密码或其他敏感信息时绝不要使用get);

 post get更安全,因为参数不会被保存在浏览器历史或 web 服务器日志中。