如何过滤$ _SERVER ['REQUEST_METHOD'] [英] How to filter $_SERVER['REQUEST_METHOD']

查看:139
本文介绍了如何过滤$ _SERVER ['REQUEST_METHOD']的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下代码检查表单是否安全?

Is it safe to check if a form is submitted with below code?

if( $_SERVER['REQUEST_METHOD'] === 'POST' )  



当我在Netbeans中写这个时,它建议使用一些过滤功能。是否有必要做类似


When I write this in Netbeans it suggests to use some filtering function. Is it necessary to do something like

$RequestMethod = filter_input(INPUT_SERVER, 'REQUEST_METHOD', FILTER_SANITIZE_STRING);
if ( $RequestMethod === 'POST' )
{
// Form data is posted to the page so ...
}



我不清楚第3个参数在这里。我应该使用什么样的过滤?


And I don't clearly understand the 3rd parameter here. What kind of filtering should I use?

推荐答案

_SERVER [' REQUEST_METHOD'] === ' POST'
_SERVER['REQUEST_METHOD'] === 'POST' )



当我在Netbeans中写这个时,它建议使用一些过滤功能。是否有必要做类似


When I write this in Netbeans it suggests to use some filtering function. Is it necessary to do something like


RequestMethod = filter_input(INPUT_SERVER,' REQUEST_METHOD',FILTER_SANITIZE_STRING);
if
RequestMethod = filter_input(INPUT_SERVER, 'REQUEST_METHOD', FILTER_SANITIZE_STRING); if (


RequestMethod === < span class =code-string>' POST'
{
// 表格数据发布到页面上......
}
RequestMethod === 'POST' ) { // Form data is posted to the page so ... }



我在这里并不清楚第3个参数。我应该使用什么样的过滤?


And I don't clearly understand the 3rd parameter here. What kind of filtering should I use?


这篇关于如何过滤$ _SERVER ['REQUEST_METHOD']的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆