See if I can explain this the best I can.
I have an admin panel that I created in Flash.
Client has differnet buttons that load a differnet text editor for each section, News/Bio/Results etc etc.
When the swf loads up I have it set up so that the input field that they edit gets populated by what the .txt file already has in it.
Then they can just add or over write what they want to.
The problem is, when they hit the submit button, the php file does not recognize the pre-existing line breaks that are there.
Say the field has this in it.
**My name is JJ, Welcome to my site. **
I hope you have a fun time here.
Then you type this to add something.
My name is JJ, welcome to my site.
I hope you have a fun time here.
While your here don’t forget to email me.
Then if you hit submit. You will get this.
My name is JJ, welcome to my site.I hope you have a fun time here.While your here don’t forget to email me.
Everything gets grouped together and the line breaks go bye bye.
Here is what I have in Flash.
myIdentifier = Math.round(Math.random()*100000);
loadVarsText = new LoadVars();
newsInput.html = true;
loadVarsText.onLoad = function(success) {
if (success) {
trace("done loading");
newsInput.htmlText = this.news;
} else {
trace("not loaded");
}
};
loadVarsText.load("news.txt?uniq="+myIdentifier);
submit1.onPress = function() {
mask.gotoAndPlay(2);
submit1._visible = false;
};
submit.onPress = function() {
if (newsInput.text != "") {
myData.news = newsInput.text;
myData.sendAndLoad("news.php", myData, "POST");
}
};
myData = new LoadVars();
myData.onLoad = function() {
if (this.writing == "Ok") {
status.text = "Submited data was saved";
mask.gotoAndStop(1);
submit1._visible = true;
} else {
status.text = "Error in saving submitted data";
}
};
stop();
Here is the PHP code
<?php
$news = $_POST['news'];
$toSave = "news=".$news;
$fp = fopen("news.txt", "w");
if(fwrite($fp, $toSave)) echo "writing=Ok";
else echo "writing=Error";
fclose($fp);
?>
Basically I want what is there to begin with to stay formatted the same way it was previously. And if they add to it, to add it to the end with the line break before it.
I can change the w to a+ to make it add to it, but that takes away the feature of the client seeing what is already in the txt file.
Does that make any since?
I am not a PHP guru by any means, so I dont even know if that is correct above.
Josh