从POST与GET、REQUEST响应的php和asp写法对比谈数据过滤
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<meta charset="UTF-8">
<title>fuck</title>
</head>
<body>
<?php
$q = isset($_POST['q'])? htmlspecialchars($_POST['q']) : '';
if($q) {
if($q =='RUNOOB') {
echo '菜鸟教程<br>http://www.runoob.com';
} else if($q =='GOOGLE') {
echo 'Google 搜索<br>http://www.google.com';
} else if($q =='TAOBAO') {
echo '淘宝<br>http://www.taobao.com';
}
} else {
?>
<form action="" method="get">
<select name="q">
<option value="">选择一个站点:</option>
<option value="RUNOOB">Runoob</option>
<option value="GOOGLE">Google</option>
<option value="TAOBAO">Taobao</option>
</select>
<input type="submit" value="提交">
</form>
<?php
}
?>
</body>
</html>
php:
$_GET 接受get传递
$_POST接受post传递
$_COOKIE接受cookie传递
$_REQUEST get post 都能接受
表单method使用get,被响应的php(表单种action提交指向的php)可以使用$_GET、$REQUEST
表单method使用post,被响应处理的php可以使用$_POST、$_REQUEST
asp:
Request.querystring 接受get
Request.form接受post
Request.cookie 接受cookie
Request接受get和post
过滤:从cookie(cookie表单) get(url请求) post(表单)对用户数据过滤
除此还有http头里面有些UA回有回显,也存在注入或者跨站的风险