How to dump FORM POST data to screen?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gmrobert
Forum Newbie
Posts: 22
Joined: Wed Oct 04, 2006 9:07 am

How to dump FORM POST data to screen?

Post 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
DrTom
Forum Commoner
Posts: 60
Joined: Wed Aug 02, 2006 8:40 am
Location: Las Vegas

Post 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("&nbsp;","<br>"),$dump);
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Code: Select all

print_r($_POST);
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
DrTom
Forum Commoner
Posts: 60
Joined: Wed Aug 02, 2006 8:40 am
Location: Las Vegas

Post by DrTom »

The Ninja Space Goat wrote:

Code: Select all

print_r($_POST);
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.
gmrobert
Forum Newbie
Posts: 22
Joined: Wed Oct 04, 2006 9:07 am

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post 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.
(#10850)
gmrobert
Forum Newbie
Posts: 22
Joined: Wed Oct 04, 2006 9:07 am

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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?
gmrobert
Forum Newbie
Posts: 22
Joined: Wed Oct 04, 2006 9:07 am

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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)
gmrobert
Forum Newbie
Posts: 22
Joined: Wed Oct 04, 2006 9:07 am

Post 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
Post Reply