Hi ,
I am designing website forms and on submittion i am writing them to xml file. now i am posting XML request to another application server which
record the form data in it. Now what i require is :
How to make daemon process in php so that after some interval of time it runs the script/page which post the XML request to the server.
After i post the XML request i got the reponse from the server.. how to read that response from the server.
this is code of PHP file :
<?php
// a file contain post data
$file = "abc.xml";
$remote_url = "/xmlengine";
$remote_server = "localhost";
// read post data
$data = file($file);
// built up POST data
$request = "";
for ($i=0;$i<count($data);$i++)
{
$request .= $data[$i];
}
// Build the header
$header = "POST $remote_url HTTP/1.0\r\n";
$header .= "Host: $remote_server\r\n";
$header .= "Content-type: text/xml\r\n";
$header .= "Content-length: " . strlen($request) . "\r\n\r\n";
// Open the connection
$fp = fsockopen($remote_server, 8090);
if ($fp)
{
// Send HTTP request
fputs($fp, $header . $request);
print "HEADER :: <br/>" . $header . $request;
// Get the response
$response="";
while (!feof($fp))
$response .= fgets($fp, 128);
fclose($fp);
print "RESPONSE :: <br />" . $response;
}
else
die ("Cannot connect!");
?>
Please treat it as urgent.
Have a nice day
~Anand