PDA

View Full Version : Flash/PHP save to text file



DirtyApe
January 22nd, 2006, 11:30 AM
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:




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()


And here is the PHP code:


<?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.

Ben Smith
January 22nd, 2006, 05:12 PM
Yeah, you'd have to chmod it to 777 I think