[quoted text, click to view] > You'll have two files, a PHP file which is basically a middle-man proxy.
I meant to say:
You'll have two files, a PHP file which is basically a middle-man proxy, and
an XML file--in addition to your Flash SWF and HTMLs files, etc.
Here is a small PHP script which is doing exactly what we are talking about.
It takes POST data, opens an XML file, creates a new node with some attributes
based on the POST data, and saves it to back to file. I'm also doing some
checks to make sure the data is not too big or incorrect, to prevent malicious
attempts.
if(count($_POST) == 4
&& strlen($_POST['fname']) <= 50
&& strlen($_POST['lname']) <= 50
&& strlen($_POST['email']) <= 50
&& strlen($_POST['comment']) <= 250){
foreach ($_POST AS $key => $val)
$_POST[$key] = stripslashes($_POST[$key]);
$dom = new DomDocument();
$dom->load("guestbook.xml");
$node = $dom->createElement("comment");
//attr: name
appendChildAttribute($dom,$node,"fname",$_POST['fname']);
//attr: favkind
appendChildAttribute($dom,$node,"lname",$_POST['lname']);
//attr: fav
appendChildAttribute($dom,$node,"email",$_POST['email']);
//append new node
$node->appendChild($dom->createTextNode($_POST['comment']));
$dom->documentElement->appendChild($node);
// Echo the output
//header('Content-type: text/xml');
//echo $dom->saveXML();
// Save to file
$dom->save("guestbook.xml");
}else{
echo "Invalid submission";
}
function appendChildAttribute($dom, $node, $attributeName, $attributeValue){
$attr = $dom->createAttribute($attributeName); //create attribute
$attr->appendChild($dom->createTextNode($attributeValue)); //assign
attribute value
$node->appendChild($attr); //add the attribute to node
}