PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hi All,
I am having trouble writing a php script to have the data be written into xml. I am trying to take the variables from flash and have it run through a php script and write into an xml file. I am trying to tweak a php script that I know works that used to send me an email but now instead of sending me an email I want it to write the data it collects into an xml file but am currently having issues. Any help at all is greatly appreciated. Thanks in advanced,
BC
<?php
// read the variables from flash
$name = $_POST['yourname'];
$email = $_POST['youremail'];
$message = $_POST['yourmessage'];
// include sender IP in the message.
$ipaddress = "Sender's IP Address: " . $_SERVER['REMOTE_ADDR'];
// remove the backslashes that normally appears when entering " or '
$name = stripslashes($name);
$email = stripslashes($email);
$message = stripslashes($message);
// write to xml file
if(isset($name) and isset($email) and isset($message)){
$handle = fopen("/guestbook.xml", "w");
fwrite($handle, $name, $email, $ipaddress, $message);
}
?>
it seems there is already a simple answer but i happen to be doing the exact same thing so i thought i would go ahead and put in my solution: rather than having php insert new lines to my xml file, i load the xml file to flash, add to it/delete items/etc... in flash and then post the whole edited xml to my php script using urlvariables.
it overwrites the whole file with the new one. in my final version i plan on using the technique to save an unedited version of the xml to a file editMe-old.xml.
cheers.brook