In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "how to solve the problem that php post cannot receive data". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
php post does not receive data solutions: 1, php.ini max_input_vars changed to 5000;2, through the "$GLOBALS <$'HTTP_RAW_POST_DATA']" to get data.
Operating environment: Windows 7 system, PHP7.1 version, DELL G3 computer
One: PHP uses POST to get some data problems
A project developed using PHP, in the beta phase customer feedback said the data was not saved successfully
I passed the test before, but the problem was reproduced on the customer information.
question is this
Customers save through the browser, but some data has been saved successfully, but some data has not been saved successfully
And I found through testing that $_POST some data is not, but some is
file_get_contents("php://input"); this method can also get data, but because the data needs to be processed, plus the code needs to make a lot of changes
So think about it or solve the $_POST problem
At first, I was also very puzzled. All the problems encountered before were that $_POST could not get all the information, but it was the first time I could only get some information.
Since $_POST is able to submit data, then either some data before submission is not sent to the background, or the background does not receive it.
By checking the browser request and did not find any problems, all data is sent normally
Then, the background has not been acquired.
In my tests, I found that I manually deleted the submitted data and then submitted it
$_POST in the background can get all the data, and then search on the Internet
Only to find that the data submitted by $_POST has a size limit
Then change max_input_vars in php.ini to 5000 for perfect solution
Second: $_POST in php does not receive the front-end data solution
By default, the front-end request type is Content-Type:application/x-www-form-urlencoded. Use $_POST to get the data.
If the front-end request type is Content-Type:application/json, you cannot fetch data using $_POST alone. (For example, axios of vue.js, default mode is application/json)
This can be obtained by $GLOBALS ['HTTP_RAW_POST_DATA'], and then converted to an object using json_decode, as shown below
$mypost = $GLOBALS['HTTP_RAW_POST_DATA']$postdata = json_decode($mypost);$username = $postdata->username;
If prompted Undefined index: HTTP_RAW_POST_DATA, change the code to the following.
$mypost = isset($GLOBALS['HTTP_RAW_POST_DATA'])?$ GLOBALS ['HTTP_RAW_POST_DATA']:file_get_contents("php://input");$postdata = json_decode($mypost);$username = $postdata->username;"How to solve php post receiving no data problem" content introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.