accessing header content...

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
anubis
Forum Newbie
Posts: 5
Joined: Thu Oct 13, 2005 5:05 pm

accessing header content...

Post by anubis »

Hi all,

How could I access header content sent by another server after I have made a form post??

e.g.

after posting following form to x.com

<form name="theForm" action="http://www.x.com/process.php" method="post">
<input type="hidden" name="var1" value="someValue">
</form>

they're supposed to reply with an xml message, how can I access this response using php, maybe store it in a var??

tnx buckets :D
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

If you mean you want to access the data contained within that form, then simply use the $_POST global.

In that exact case, it would be $_POST['var1']
anubis
Forum Newbie
Posts: 5
Joined: Thu Oct 13, 2005 5:05 pm

accessing response

Post by anubis »

no, I want to access whatever the page "url in form action" outputs.


so say....http://www.x.com/process.php

outputs:

<message>
<errorcode>105</errorcode>
</message>

I want to be able to process this after i make my form post...is there a way in php to parse the header content returned after a form post??
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

How are you making your request? If by GET, file_get_contents() does a fine job at receiving http responses.

If POST, the most basic way would be using sockets.
User avatar
jwalsh
Forum Contributor
Posts: 202
Joined: Sat Jan 03, 2004 4:55 pm
Location: Cleveland, OH

Post by jwalsh »

I'd be very interested in learning how to do this with sockets. What can I google to bring up this topic? I'm having a hard time researching it.

Thanks!

Josh
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

Last edited by josh on Thu Oct 13, 2005 10:01 pm, edited 1 time in total.
User avatar
jwalsh
Forum Contributor
Posts: 202
Joined: Sat Jan 03, 2004 4:55 pm
Location: Cleveland, OH

Post by jwalsh »

Thanks, I appreciate it very much.
anubis
Forum Newbie
Posts: 5
Joined: Thu Oct 13, 2005 5:05 pm

I see how GET works now...!!

Post by anubis »

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


I initially did it like this...following code is on my test.php file

Code: Select all

<form name="test" action="process.php" method="GET">
	<input type="hidden" name="flag" value="1">
</form>

<?PHP 
	print("<script language=\"javascript\">");
	print("document.forms[0].submit();");
	print("</script>");
	print(file_get_contents());
?>
============================
above didn't work, it kept directing to process.php, i did some more investigation on using file_get_contents and got it to work in a one liner as follows:

output was on test.php

print(file_get_contents("http://domain/process.php?ssi&flag=1"));

============================

this process i will use to post billing info to a payment clearance gateway and receive an xml formatted response. having said that....above solution is far from secure. I'm also trying cURL for php...as it allows post over https

so if any of y'all have insight on installing cURL with PHP binding on windows 2003 server...i'd appreciate the help!!


Cheers!!


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

installing curl on Windows is quite simple.. uncomment the file (php_curl.dll) in the php.ini file, and make sure you have the file(s) it requires..
anubis
Forum Newbie
Posts: 5
Joined: Thu Oct 13, 2005 5:05 pm

very ez!!

Post by anubis »

thats it!! 8)

so i guess it comes bundled in php already...because i do have php_curl.dll already, just had to uncomment ext in php.ini file.

Tnx
Post Reply