I have a custom CMS i\'ve built that works perfectly on my dev box (Ubuntu/PHP5+/MySQL5+).
I just moved it up to the production box for my client and now all form su
I know this question was about POST via a Form, but came here looking for answers for similar issue when POSTing with JSON content-type. Found the answer and wanted to share it as it cost me much time.
When using JSON content-type the $_POST array will not populate (only with multi-part forms I believe)
Here is what did work to correct the issue:
$rest_json = file_get_contents("php://input");
$_POST = json_decode($rest_json, true);
hope this helps someone!
same issue here!
i was trying to connect to my local server code via post request in postman, and this problem wasted my time alot!
for anyone who uses local project (e.g. postman): use your IPv4 address (type ipconfig in cmd) instead of the "localhost" keyword. in my case:
before:
localhost/app/login
after:
192.168.1.101/app/login
In addition to MRMage's post:
I had to set this variable to solve the problem that some $_POST
variables (with an large array > 1000 items) disappeared:
suhosin.request.max_vars = 2500
"request
", not "post
" was the solution...
I came across a similar yet slightly different issue and it took 2 days to understand the issue.
In my case also POST array was empty.
Then checked with file_get_contents('php://input'); and that was also empty.
Later I found that browser wasnt asking confirmation for resubmitting form data after If I refresh the page loaded after POST submission. It was directly refreshing page. But when I changed form URL to a different one it was passing POST properly and asked for resubmitting data when attempted to refresh page.
Then I checked what is wrong with actual URL . There were no fault with URL, however it was pointing to a folder without index.php in URL and I was checking POST at index.php.
Here I doubted the redirection from / to /index.php causes POST data to be lost and tested URL with appending index.php to the URL.
That Worked.
Posted it here so someone would find it helpful.
I could solve the problem using enctype="application/x-www-form-urlencoded" as the default is "text/plain". When you check in $DATA the seperator is a space for "text/plain" and a special character for the "urlencoded".
Kind regards Frank
Make sure you use name="your_variable_name" in input tag.
I mistakenly use id="your_variable_name".
I spent much time to catch the bug.