# Getting PHP to write XML to txt file

**URL:** <https://forum.kirupa.com/t/getting-php-to-write-xml-to-txt-file/189251>\
**Category:** programming\
**Created:** [May 15, 2006, 1:19pm UTC](https://forum.kirupa.com/t/getting-php-to-write-xml-to-txt-file/189251 "2006-05-15T13:19:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hectors](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/hectors/32/2118_2.png) [@hectors](https://forum.kirupa.com/u/hectors)\
**Post date:** [May 15, 2006, 1:19pm UTC](https://forum.kirupa.com/t/getting-php-to-write-xml-to-txt-file/189251/1 "2006-05-15T13:19:49Z")

</div>

Hey there, I am experimenting sending XML from Flash to a PHP page that should then write to a txt file and I can’t get this to work, the txt file remains empty and I am not getting a response from the traceMe() function that displays the status. The archive.zip contains the php fla and txt.  
Can anyone help?

Here’s my code:  
PHP:

```php
<?php
$filename = "xmloutput.txt";
$fp = fopen( $filename,"w+");
fwrite ( $fp, "$HTTP_RAW_POST_DATA" );
fclose( $fp );
print '<?xml version="1.0"?><result>LOGIN OK</result>';
?>

```

Actionscript:

```auto
//A setting up the xml object to send
var loginXML = new XML();
loginElement = loginXML.createElement("LOGIN");
loginElement.attributes.username = "hectors";
loginElement.attributes.password = "itsmysecret";
loginXML.appendChild(loginElement);
// B. Construct a XML object to hold the server's reply
loginReplyXML = new XML();
loginReplyXML.onLoad = onLoginReply;
function onLoginReply(success:Boolean):Void {
	if (success) {
		traceMe("loginReply receieved")
	} else {
		traceMe("loginReply did not load")
	}
}
// C. Send the LOGIN element to the server,
//place the reply in loginReplyXML
loginXML.sendAndLoad("xmlreader.php", loginReplyXML);

```

Thanks everyone,  
Hectors
