Forum Moderators: coopster

Message Too Old, No Replies

PHP v4.2.3 + v4.3.11

Code working on one but not the other

         

jonparker83

9:37 am on Feb 16, 2005 (gmt 0)

10+ Year Member



I'm currently using the following script to manually POST data. It seems to work fine with PHP version 4.3.11 but not on version 4.2.3. Does anyone know what why this is happening or can anyone point me in the right direction to make the necessary changes


#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!

coopster

2:04 pm on Feb 16, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



What error messages are you getting? What is/isn't happening?

jonparker83

4:03 pm on Feb 16, 2005 (gmt 0)

10+ Year Member



Sorry if I wasn't specific enough..

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 :)