Page 1 of 1
How to dump FORM POST data to screen?
Posted: Wed Oct 04, 2006 11:12 am
by gmrobert
I would like to see the raw code sent by an HTML page using the FORM POST function. I would like to mimic this data for a app I am working on.
Is there a way I can output the raw data to the screen as part of a php script?
Thanks
Greg
Posted: Wed Oct 04, 2006 11:19 am
by DrTom
var_dump()
$_POST
or for those that like less ugly stuff
Code: Select all
ob_start();
var_dump($_POST);
$dump = ob_get_contents();
ob_end_clean();
echo str_replace(Array(" ","\n"),Array(" ","<br>"),$dump);
Posted: Wed Oct 04, 2006 11:21 am
by Luke
Posted: Wed Oct 04, 2006 11:27 am
by volka
gmrobert wrote:Is there a way I can output the raw data
take a look at
http://de2.php.net/manual/en/ini.core.p ... -post-data
Posted: Wed Oct 04, 2006 11:44 am
by DrTom
The Ninja Space Goat wrote:
man I had no idea about the return parameter. That's pretty cool. But I sitll like var_dump cause it sounds cooler than print_r.
Posted: Wed Oct 04, 2006 12:21 pm
by gmrobert
Thank you for the posts, all the methods work well.
Is there a way I can see all the http code that is sent with the headers?
The info defined in
http://www.w3.org/Protocols/rfc2616...-sec4.html#sec4 is what I am after.
volka,
I think you are pointing me in the right direction but I am not sure how to implement the function you identified.
Thanks
Greg
Posted: Wed Oct 04, 2006 12:44 pm
by volka
requires php 4.3+
Code: Select all
<html>
<head><title>raw post data</title></head>
<body>
<pre><?php echo htmlentities(file_get_contents('php://input')); ?></pre>
<form method="post" action="test.php">
<div>
<input type="text" name="abc[]" />
<br />
<input type="text" name="abc[]" />
<br />
<input type="text" name="xyz" />
<br />
<input type="submit" />
</div>
</form>
</body>
</html>
for http headers see
http://de2.php.net/manual/en/function.getallheaders.php
Posted: Wed Oct 04, 2006 12:51 pm
by Christopher
gmrobert wrote:Is there a way I can see all the http code that is sent with the headers?
You might want to just try "echo phpinfo();" as it has most of the server and environment variables listed.
Posted: Wed Oct 04, 2006 2:17 pm
by gmrobert
arborint,
That function is really cool, I will definitely use it.
volka,
Your function is what I needed to know. All I need to do now is decode the format of the characters in the POST function so I can build my own mimic of a POST function to send data from my app in the same manner as a Browser.
Thank you both for all your help it has really got me headed in the right direction now.
Greg
Posted: Wed Oct 04, 2006 2:26 pm
by volka
gmrobert wrote:All I need to do now is decode the format of the characters in the POST function so I can build my own mimic of a POST function to send data from my app in the same manner as a Browser.
There scripts/classes that can assist you. E.g.
http://pear.php.net/manual/en/package.h ... client.php
What do you need to decrypt?
Posted: Wed Oct 04, 2006 2:39 pm
by gmrobert
volka,
I would like to send data from a Palm OS app to a web server. The Palm OS allows me to use sockets but then I have to write the http headers. Another solution is to use a C++ library and use a library http/https POST function. (
http://www.pdadevelopers.com/homehttps.htm).
The http/https library is fairly well documented but it does not provide much info on:
1. How to handle the data received on the Server Side (I would prefer php)
2. What are standard formats used for sending data (I would like to use the FORM POST method).
I was hoping that if I sent my data in the same manner as a http POST function I could do the Server Side stuff with php as if I was receiving a FORM POST from a Browser.
Do you have any other suggestions on how to handle this?
Do you know where I could find more technical info on the schema used for the POST data sent by the Browser to the Server?
Thank you for all your help so far it has been tremendous.
Greg
Posted: Wed Oct 04, 2006 2:46 pm
by volka
gmrobert wrote:Do you know where I could find more technical info on the schema used for the POST data sent by the Browser to the Server?
start with
http://www.w3.org/, left side: http
RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1 (Postscript), (PDF) (compressed text)
Posted: Wed Oct 04, 2006 3:07 pm
by gmrobert
That is a great link ... I think I found what I was looking for here:
http://www.zend.com/zend/spotlight/mimocsumissions.php
Thank you
Greg