S
S
spbcypher2011-09-28 14:12:49
Apache HTTP Server
spbcypher, 2011-09-28 14:12:49

Apache/PHP how to get data sent in POST?

Now I'm working on a RESTfull service, I'm sending POST data - they are registered in environment variables like $_SERVER[ 'HTTP_<VARIABLE_NAME>' ] , while the $_POST array is empty. Can you please tell me how it can be corrected to receive data via $_POST ?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
G
gro, 2011-09-28
@spbcypher

Content-Type must be specified in the request and Content-Length.

P
p4s8x, 2011-09-28
@p4s8x

php.net/manual/en/wrappers.php.php
can be read from php://input
like file_get_contents("php://input")
or else it can be in $HTTP_RAW_POST_DATA

V
Vitaly Peretyatko, 2011-09-28
@viperet

Does your service send or receive data? It's not clear from the question.
As $_SERVER['HTTP_<VARIABLE_NAME>'] data is usually logged which is passed as HTTP headers. Maybe you're sending data to your service incorrectly?

S
spbcypher, 2011-09-28
@spbcypher

adding Content-Type: application/x-www-form-urlencoded to the Request Header helped ,
and to the Request Body in the format
var1=1
var2=2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question