This content has been marked as final. Show 4 replies
>>Must you first send your test to a .PHP file, and from there change the
Yes, you must send your text to some server-side script, such as a php
script, which in turns saves the text as an .xml file - overwriting the old
one. What you'll need to do some reading/research on, is sending text to the
server from Flash (LoadVars) and saving to a text file from PHP.
var myLV = new LoadVars(); //for send
var myRV = new LoadVars(); //for response
myLV.theXML = myXMLTextField.text;
then in phpToXML.php
$myXML = $_REQUEST['theXML']; //change to $_POST for production
$myFile = "../css/myXML.xml"; //relative server path
$fh = fopen($myFile, 'w');
fwrite($fh, $myXML );
echo("&ok=1"); //whatever you want to send back to your response loadVars
you will want to add the onLoad of the response object so you can listen for
the echo back from php, but otherwise this is about all you need.
Adobe Community Expert
Thanks DMennenoh. I had already done some direct response email forms using LoadVars, so I have successfully sent info to and from a PHP file.
What I don't understand about the example you set out was, what did you mean by;
[PHP]$myXML = $_REQUEST['theXML']; //change to $_POST for production[/PHP]
Do I change $_REQUEST to $POST when I go live?
Not sure what you meant by, //change to $_POST for production.
Also, what does the 'w' represent in, [php]$fh = fopen($myFile, 'w');[/php] ?
Is this the node in the XML file you are trying to change?
Flash, in the gui sends requests using the get method, but post when in the
browser. So I like to use $_REQUEST in php, which works with either - for
testing. When live use $_POST as it's more secure. You can look up fopen in
the php docs... but I think the 'w' means write mode. You are sending the
text of the field, not a single node.
Adobe Community Expert
OK, I kinda understand.
I went to PHP.net to look up all the operators mentioned here, but what I still am having a hard time with is how to replace text in a node in the XML file with the fwrite command. I see that is writing $myXML into the XML file, but how do I direct the to replace the text string "Canada wins gold" in the XML file? Do I need to change the names of my child or parent nodes in the XML file to match the PHP language, such as <Destination>$myXML</Destination>?
Here is my current XML code.