12

I am sending data using HTTP POST to my server. But in the server, I am not receiving the data. And somehow I don't have any way to check the data (or debug script) on client side. But on the client side I am getting HTTP 200, meaning data is sent. Also I can see the connection and data sending was successful. However, log in the server doesn't contain the data (only the number of bytes).

How can I log the raw POST data that was sent to the server?

FYI, here the client is an embedded device with very limited capability, so this is a problem. I can not check "print_r" or "echo".

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Morison
  • 1,105
  • 3
  • 17
  • 34
  • What happens if you try a print_r($_POST)? – Martin Hennings Sep 15 '10 at 13:56
  • unfortunately I can not see that in client side. So,it will not work. – Morison Sep 15 '10 at 13:59
  • Were you able to reproduce the problem with some other client that is more potent (and able to run things like firebug ^^)? – Martin Hennings Sep 15 '10 at 14:03
  • Wait - so it's a closed server (you cannot get access) you're sending data but you don't know why it's not showing? This is a black box problem - the software could be doing ANYTHING to your data including ignoring it, storing it somewhere else, encoding it, cleaning the kitchen sink with it - this isn't a PHP or MySQL question in that case. – Rudu Sep 15 '10 at 14:03
  • @Rudi - I don't think that he's on a closed server. Just the problem that any debugging information can only be output to either some data storage (SQL, file, ...) or to the caller (who is unable to display that data). – Martin Hennings Sep 15 '10 at 14:10
  • yeah, that's right. Thanks Martin. Sorry, I forgot to respond on Rudi's comment. – Morison Sep 15 '10 at 15:05

3 Answers3

28

You can see the content of POST data inline (not for production) with:

print_r($_POST);

Or if you want to see POST, GET and COOKIE data:

print_r($_REQUEST);

If you need to log, since the client is very limited - try outputting the POST data to a file:

file_put_contents("post.log", print_r($_POST, true));
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Rudu
  • 15,346
  • 4
  • 45
  • 63
11

Write POST data to a file:

file_put_contents('/tmp/postdata.txt', var_export($_POST, true));
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Sjoerd
  • 71,634
  • 16
  • 123
  • 171
1

You can try sniffing the HTTP session.

Sjoerd
  • 71,634
  • 16
  • 123
  • 171