您好,欢迎访问一九零五行业门户网

PHP $_POST接受不到数据,但$_GET可以接受数据

新手一枚,代码如下,把post 改成 get 就没问题,但如果是post 就会提示
notice: undefined index: a in d:\xampp\htdocs\myphp\add.php on line 3
add.html
title a:
b:


add.php


回复内容: 新手一枚,代码如下,把post 改成 get 就没问题,但如果是post 就会提示
notice: undefined index: a in d:\xampp\htdocs\myphp\add.php on line 3
add.html
title a:
b:


add.php


我也是类似的问题,只有一种可能,就是你得phpstrom配置的端口与phpinfo()端口不符。先看一下的端口在哪里比如localhost,那么就配置phpstrom-》tools-》dployment-》configuration-》
新建比如name=localhost,然后设置web sever root url为http://localhost,端口与phpinfo()端口一致即可
php.ini 中配置 enable_post_data_reading 为 on, 这样才会自动将 post 数据填入 $_post 数组中。
; whether php will read the post data.; this option is enabled by default.; most likely, you won't want to disable this option globally. it causes $_post; and $_files to always be empty; the only way you will be able to read the; post data will be through the php://input stream wrapper. this can be useful; to proxy requests or to process the post data in a memory efficient fashion.; http://php.net/enable-post-data-reading; enable_post_data_reading = off
判断是否输入a和b的值,应该使用:
isset($_post['a']) && isset($_post['b']
你的写法在a或b输入0值时,不会走相加分支。
打印 $_request数组,
如果查验是否有数据post过来,如果没有确定的条件下,推荐在业务处理前先进行打印数据。
上面可以直接
var_dump($_post);
看下是否有值。
post有好几种方式,你看你是什么方式提交的?
php配置问题吧
其它类似信息

推荐信息