Forum Moderators: coopster
#the following function performs a HTTP Post and returns the whole response
function pullpage( $host, $usepath, $postdata = "" ) {
# open socket to filehandle(epdq encryption cgi)
$fp = fsockopen( $host, 80, &$errno, &$errstr, 60 );
#check that the socket has been opened successfully
if(!$fp ) {
print "$errstr ($errno)<br>\n";
}
else {
#write the data to the encryption cgi
fputs( $fp, "POST $usepath HTTP/1.0\n");
$strlength = strlen( $postdata );
fputs( $fp, "Content-type: application/x-www-form-urlencoded\n" );
fputs( $fp, "Content-length: ".$strlength."\n\n" );
fputs( $fp, $postdata."\n\n" );
#clear the response data
$output = "";
#read the response from the remote cgi
#while content exists, keep retrieving document in 1K chunks
while(!feof( $fp ) ) {
$output .= fgets( $fp, 1024);
}
#close the socket connection
fclose( $fp);
}
#Ireturn the response
return $output;
}
Thanks very much!
I've been using the function to POST variables to a page and then extract information out of the respsonse.
With the newer version of php, there is no problem but with version 4.2.3, no response is returned
I was wondering if it was the difference in PHP versions causing the problem and if there is any way to rectify this
Thanks a lot :)