How can I get this to save more text feilds than just one?
fla
http://spamtheweb.com/ul/upload/071009/7 2755_loadVarsSendAndLoad_writeIntxtFile_
deamothul.fla
PHP code:
<?
//this are the variables that will hold the data send from flash via the input textbox
//the data is send by the sending part of the loadVars object
//inputData is a variable we will set in flash, its a variable attached to the loadVars object and will be send to this php script.
$receivedFromFlashData = $_POST['inputData'];
//this is to make our textfile readable and writable
//we place it in a variable so that we can refer back to it easilly.(b.t.w. the @ symbol is to hold back certain error messages)
$myTextFileHandler = @fopen("myTextFile.txt","r+");
//With @file we will turn our textfile into an array so we can know how many entries there are in the file.
$txtfileArray = @file("myTextFile.txt");
//here we check if we could open the file and thus if everything is ok to go on.
if($myTextFileHandler){
//a print to help us when we run our php file through the browser, so this will not be send to flash.
print("txtFile is opened\n");
//loop through the text file array remember ---> @file("membersDatabase.txt");
//we use the $count variable in the string we send to the text file,it attaches a number to the string for us
//to show how may times we inserted someting into the textfile.
foreach($txtfileArray as $count => $member);
//We go to the last byte of the file, because we want to insert data at the end of the file
$gotoLastByteOfTxTFile = @fseek($myTextFileHandler,0,SEEK_END);
//Increase count by one because an array starts counting at 0.
$count = $count + 1;
//Here we make a variable writeInTxtFile with the command @fwrite.
//It will write a string into the text file defined in myTextFileHandler, notice the \n makes it start on a new line each time .
$writeInTxtFile = @fwrite($myTextFileHandler,"\nreceived data from flash $count = $receivedFromFlashData");
//Was writing into the txtfile a success , if true print a variable to flash to be handled in the response loadVars Object.
if($writeInTxtFile){
//Here we make a variable to hold the message we wanna show in flash if writing to the textfile was a succes.
$writeStatus = "writing to textfile was a succes";
//This is printed to flash and this piece of data is actually attached to the loadvars object we defined in flash.
//So you can acces it just like you would a variable in a movieclip or object.
//so you can set this variable to be show in a textbox like this:
// mytextbox.text = myReveivingLoadvars.writeStatus
// this piece of code must be triggered in the myReveivingLoadvars.onLoad part
print("&writeStatus=$writeStatus");
//if writing was a failure we print that to flash
}else{
$writeStatus = "writing to textfile was a big failure";
print("&writeStatus=$writeStatus");
};
//here we close the stream to the textfile
@fclose($myTextFileHandler);
//If opening the text file was a failure in the first place we print this to the php output.
//You could choose to also send error messages like this to flash, just change the print command to something like:
//print("&failMsg = $youErrorMsg"); and call the failMsg variable in your flash file in the receiving onLoad part of
//the loadVars object e.g. like myTextBox.text = myReceiveLV.failMsg.
}else{
print("opening txtfile has failed\n");
};
//this is printed to flash and received by the reveiver part of our loadVars object.
//this piece of data will be show in a textbox in flash immediately after a you press submit.
// so you sumbit your inputted text in flash , its ran through this little engine like php script and you immediately receive
// an answer back.
print("&receivedData=$receivedFromFlashData");
?>