hi , Please check this link.. http://www.alt-php-faq.org/local/55/
u may get some idea.. ~Pallav [EMAIL PROTECTED] wrote: ----- Original Message ----- I am able to use an html form page to post to a PHP script. The html form hits a PHP file, which reads the $_POST variables and does various stuff. I need to do have a different PHP script do what the html form does: post the the PHP file. When I try the following code: $header .= "$method http://$host$path HTTP/1.1\r\n"; $header .= "Host:$host\r\n"; $header .= "Content-Type: multipart/form-data\r\n"; $header .= "Content-Length: " . strlen($data) . "\r\n\r\n"; $header .= "Connection: Keep-Alive\r\n\r\n"; $method = strtoupper($method); $fp = fsockopen ($host, 80, $errno, $errstr, 30); if (!$fp) { $res="error"; } else { fputs ($fp, $header.$data); while (!feof($fp)) { $res .= fgets ($fp, 1024); } fclose ($fp); } Even though I had said Keep-Alive, I immediately get this: Response:HTTP/1.1 200 OK Date: Fri, 15 Feb 2008 07:26:43 GMT Server: Apache Connection: close Transfer-Encoding: chunked Content-Type: text/html 0 It does not perform the code in my targtet PHP script. It just returns immediately. Does anyone know how to post from one PHP script to another, just like a form would do? ----------------------------- A header is terminated with the first "\r\n\r\n" so your second line below is ignored - $header .= "Content-Length: " . strlen($data) . "\r\n\r\n"; $header .= "Connection: Keep-Alive\r\n\r\n"; the first line should be - $header .= "Content-Length: " . strlen($data) . "\r\n"; Also you have - $header .= "$method http://$host$path HTTP/1.1\r\n"; after the below - $method = strtoupper($method); I am assuming $method == "post" OR "POST" One other thing - This code seems to be writen for php 4.x.x - it is much easier to do in php 5.x.x code. Rob. --------------------------------- Support the World Aids Awareness campaign this month with Yahoo! for Good [Non-text portions of this message have been removed]
