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?

Reply via email to