Page 1 of 1
accessing header content...
Posted: Thu Oct 13, 2005 5:16 pm
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

Posted: Thu Oct 13, 2005 6:59 pm
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']
accessing response
Posted: Thu Oct 13, 2005 7:40 pm
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??
Posted: Thu Oct 13, 2005 9:56 pm
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.
Posted: Thu Oct 13, 2005 9:58 pm
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
Posted: Thu Oct 13, 2005 9:59 pm
by josh
Posted: Thu Oct 13, 2005 10:00 pm
by jwalsh
Thanks, I appreciate it very much.
I see how GET works now...!!
Posted: Thu Oct 13, 2005 10:40 pm
by anubis
feyd | Please use 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
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Posted: Thu Oct 13, 2005 11:01 pm
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..
very ez!!
Posted: Thu Oct 13, 2005 11:11 pm
by anubis
thats it!!
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