# Flash/PHP save to text file

**URL:** <https://forum.kirupa.com/t/flash-php-save-to-text-file/176292>\
**Category:** programming\
**Created:** [January 22, 2006, 4:30pm UTC](https://forum.kirupa.com/t/flash-php-save-to-text-file/176292 "2006-01-22T16:30:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DirtyApe](https://avatars.discourse-cdn.com/v4/letter/d/c37758/32.png) [@DirtyApe](https://forum.kirupa.com/u/DirtyApe)\
**Post date:** [January 22, 2006, 4:30pm UTC](https://forum.kirupa.com/t/flash-php-save-to-text-file/176292/1 "2006-01-22T16:30:32Z")

</div>

I found a good tutorial explaining how to save data from a Flash form into a text file. But something is wrong because it isn’t working on my server (which has PHP support). Here is the actionscript:

[LEFT]

```auto
 [LEFT]submit.onPress = function(){
if(Title.text!="" && Comments.text !=""){
myData.Title = Title.text
myData.Comments = Comments.text
myData.sendAndLoad("save.php", myData, "POST")
}
}
myData = new LoadVars()
myData.onLoad = function(){
   if(this.writing=="Ok") {
   gotoAndStop(2)    
   status.text = "Submited data was saved"
   }
   else status.text = "Error in saving submitted data"
}
stop()[/LEFT]

```

And here is the PHP code:

[COLOR=#000000][COLOR=#0000bb]

```php
 <?php 
   $title = $_POST['Title']; 
   $comments = $_POST['Comments']; 
   $toSave = "Title=".$title."&Comments=".$comments.; 
   $fp = fopen("news.txt", "w"); 
   if(fwrite($fp, $toSave)) echo "writing=Ok"; 
   else echo "writing=Error"; 
   fclose($fp);    
?>

```

Is there something wrong in these scripts? I was also reading about chmod permissions on another site, would I have to change these for the file to work? I pretty confused about what’s wrong. My Flash file is also attached, I’ll appreciate any help.[/COLOR][/COLOR][/LEFT]
