Hello list, I'm attempting to use the PostToHost() function to send a request to a remote script. The purpose for this is to request and retrieve information from a remote database without the need for messy HTTP & HTML methods. I realize that I could use an HTML form, put the data in hidden fields, and send the request that way, but then I would have to redirect back from the master script recording an unwanted page in the 'Back Button' history. I'd like to avoid that so I'm investigating methods of POST'ing through a manual socket connection.
Here is that PostToHost() function.. /********************************************************* PostToHost($host, $path, $data_to_send) $host; valid domain (ie. www.domain.com) $path; relative URL (ie. /myfile.php) $data_to_send; urlencoded key/val string (ie. "key=val&key2=val2&key3=val3") *********************************************************/ function PostToHost($host, $path, $data_to_send) { ob_end_flush(); $fp = fsockopen($host,80); fputs($fp, "POST $path HTTP/1.0\n"); fputs($fp, "Host: $host\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\n"); fputs($fp, "Content-length: " . strlen($data_to_send) . "\n"); fputs($fp, "Connection: close\n\n"); fputs($fp, $data_to_send); while(!feof($fp)) { echo fgets($fp, 128); } fclose($fp); } It works great! The only problem is I get output from the socket connection and I don't know how to skip over it... HTTP/1.1 200 OK Date: Mon, 16 Jun 2003 20:10:36 GMT Server: Apache/1.3.20 (Unix) ApacheJServ/1.1.2 PHP/4.2.3 FrontPage/5.0.2.2510 Rewrit/1.1a X-Powered-By: PHP/4.2.3 Connection: close Content-Type: text/html I'm very much a newbie to all of this so you'll have to forgive me. But I'm wondering if there is anyway to avoid this output and have a completely invisible manual socket POST? Thanks, Kevin Stone [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php