PHP Settings? PHP not receiving POST data
Asked Answered
H

7

10

I’m sending a .php file POST data from a java application. The .php file is not accepting the POST data. file_get_contents(‘php://input’) is empty and $_POST is empty. I know the problem isn’t with the .php file or java application because I tested it using a different host and it worked. Is there a setting in php.ini I’m missing or a setting I need to change?

Honeyhoneybee answered 3/8, 2011 at 8:29 Comment(4)
Can you describe your server environment.Hekking
maybe you have this problem #5541862Premonitory
Check for max post size, and uploaded files in PHP appears in $_FILES not $_POSTBriant
I have godaddy unlimited package.Honeyhoneybee
N
19

I had this problem too. For future visitors, my issue was missing the trailing slash in the url. Eg..

http://someplace.com/cheeseburger

should have been...

http://someplace.com/cheeseburger/

This was causing the post to fail, in my case.

Norenenorfleet answered 1/6, 2016 at 14:33 Comment(6)
How did you ever figure this out? I don't think I'd ever have figured this out!Heterograft
How in the world did this work....thank goodness I found this suggestion...Sauder
Love You 3000... I have been trying from months but couldn't find a solution. Today somehow I came through your answer, tried it, and it just worked. Thanks a lot...Parget
Super thanks. You answer solved my problem.Sideline
OMG...Two days of pounding my head on my desk and it was this simple.Sileas
Thanks! This saved me from a headache! I didn't know there was such a difference between these, maybe at least on Apache.Grazynagreabe
H
16

If the Content-Type is empty or not recognized in the HTTP message then the PHP $_POST array is empty. If you cannot send the Content-Type you can add this to your PHP:

if(empty($_SERVER['CONTENT_TYPE']))
{ 
 $_SERVER['CONTENT_TYPE'] = "application/x-www-form-urlencoded"; 
}

You can also check if you have the correct settings in your php.ini

; Maximum size of POST data that PHP will accept.
post_max_size = 8M

If post_max_size is 0, PHP will not populate $_POST.

variables_order = "EGPCS"

If you do not have P in there, $_POST will not be set either.

Hafler answered 3/8, 2011 at 8:34 Comment(3)
I tried that, but it didn't work. I don't see how it could work on one host but not work on another. Godaddy is my host. It doesn't work on Godaddy, but it works perfectly fine on hosting24.comHoneyhoneybee
The max size is 128M. P is in there.Honeyhoneybee
Another idea would be doing a diff between the php.ini files of the two servers.Hafler
B
3

I had the same issue. The problem was http:// and https://

Benyamin answered 22/8, 2020 at 9:56 Comment(0)
K
2

I was having the same problem. It turned out to be because I was prefixing my target with http . I changed it to https and it worked.

Krystenkrystin answered 16/8, 2019 at 16:9 Comment(0)
H
0

My problem was duplicate names for an input.

ex: /input name="test" type="text" / /input name="test" type="text" /

each must have a different name ex: /input name="testA" type="text" / /input name="testB" type="text" /

Haase answered 20/8, 2018 at 14:3 Comment(0)
L
0

My problem appeared out of nowhere. I'm using an apache hack to hide the extension, so all I had to do is to remove .php from the file name and it worked.

/* from: */ action = "folder/filename.php"
/* to: */   action = "folder/filename"

I hope this answer helps someone else in the same situation 😎

Liable answered 18/6, 2022 at 20:45 Comment(0)
T
0

My problem was that I was requesting to http instead of https
Due to using Cloudflare proxy and I was not forced to switch from http to https
So it still returns the result but the POST is not received.

Toor answered 21/8 at 10:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.