php post提交数据 $_post为空 file_get_content(php://input)可以获取到 这是为什么呢?
环境是用mamp安装的
form提交的代码如下:
管理员帐号 密码 验证码 自动登陆(一周内自动登陆)
dologin.php的代码如下
include_once '../include.php';$username = $_post['username'];$password = md5($_post['password']);$verify = $_post['verify'];$session_verify = $_session['verify'];var_dump($_post);var_dump($_server);
用花瓶抓包的结果:
回复内容: php post提交数据 $_post为空 file_get_content(php://input)可以获取到 这是为什么呢?
环境是用mamp安装的
form提交的代码如下:
管理员帐号 密码 验证码 自动登陆(一周内自动登陆)
dologin.php的代码如下
include_once '../include.php';$username = $_post['username'];$password = md5($_post['password']);$verify = $_post['verify'];$session_verify = $_session['verify'];var_dump($_post);var_dump($_server);
用花瓶抓包的结果:
首先php://input是不受php.ini设置行为的影响,可以直接获取到post的原始数据的.
而$_post是有受限于头限制的.英文手册(中文手册没有这段,略坑)中有如下介绍:
an associative array of variables passed to the current script via the http post method when using application/x-www-form-urlencoded or multipart/form-data as the http content-type in the request.
也就是你的content-type 只有是application/x-www-form-urlencoded 或者multipart/form-data的时候,才会被预定义的变量$_post收进去.
另外一种情况可以考虑用$http_raw_post_data,这个跟php://input获取到的数据是一样的,但是这个变量有受到php.ini中的选项always_populate_raw_post_data的限制.
form action=dologin.php 这里action的地址写成全路径试试。
action=./dologin.php