I'm working on a project that submits xml from a client using the xmlhttprequest command in javascript. Then, a php script I've written is supposed to receive the post request, and respond. I'm a newbie when it comes to processing xml requests in php, so I could use some help.
Right now, the client is successfully requesting my php script, and passing the xml data in post format. However, when I try to write the post data to a file in order to verify it's been sent, nothing shows up. only the "Output: " text from the top is displayed in my file.
Here's the php code so far:
Code: Select all
<?php
//write any post requests to a file so I can see what is being returned
$filename = 'xml_log.txt';
$fp = fopen($filename, "a");
$op = "Output: \n";
$xml = simplexml_load_string($_POST);
if (!empty($_POST)) {
foreach ($_POST as $k => $v) {
$op = $op . "$k: $v\n";
}
exit;
}
if (!empty($_GET)) {
foreach ($_GET as $k => $v) {
$op = $op . "$k: $v\n";
}
exit;
}
$write = fputs($fp, $op);
fclose($fp);
?>