Craig Ward
Craig Ward

Reputation: 2485

PHP $_POST empty on remote submission

If I post data to a test script on my web server (from a remote source) the $_POST array is empty but HTTP_RAW_POST_DATA has the posted information.

Data posted locally with a form works fine.

The server is Ubuntu 12.04/Apache/PHP 5.3.10, its a standard build.

UPDATE

Im using this to test the endpoint https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo/

This is the REST server I am implementing https://github.com/philsturgeon/codeigniter-restserver. Its been installed on a standard LAMP stack, and a fresh codeigniter install.

There are no redirects happening.

Upvotes: 1

Views: 802

Answers (2)

pvnarula
pvnarula

Reputation: 2821

1. $_POST contains URL encoded (application/www-url-encoded) variables that are posted to your script and PHP decodes them for you. You use this one when you deal with HTML FORM data.

2. $HTTP_RAW_POST_DATA - gets the raw POST data and you need to use this when you write APIs and need XML/JSON/... input that cannot be decoded to $_POST by PHP.

Upvotes: 1

Lochemage
Lochemage

Reputation: 3974

Are you sure you're not getting some kind of redirection? For example, you send post data to http://somedomain.com and it auto redirects you to https://somedomain.com or http://www.somedomain.com... You will lose your post data that way.

Upvotes: 2

Related Questions