Forum Topic: Save more input text feilds?

(110 views • 5 replies)

This topic is 1 page long.

<< < > >>
None

djbdr248

Reply To Post Reply & Quote

Posted at: 10/7/09 08:13 PM

djbdr248 EVIL LEVEL 11

Sign-Up: 08/07/07

Posts: 885

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"); 


?>

None

djbdr248

Reply To Post Reply & Quote

Posted at: 10/7/09 08:16 PM

djbdr248 EVIL LEVEL 11

Sign-Up: 08/07/07

Posts: 885

AS2 Code:

//First we write a function to... well the name says it all. 
function submitDataToTextfile() {      
     //this is our sending loadVars object, it sends the data to the php file so that it can be processed.      
     submittedData = new LoadVars();      
     
     //here we make a variable "inputData" and as value we set it to the value of the inputData textfield.      
     submittedData.inputData = inputData.text;      
     
     //this is our response loadVars object, it is responsible for receiving data from the php script immediately      
     //when submit is pressed it will receive its data      
     response = new LoadVars();      
     
     // this is an importatn part to understand, we execute the function "doThisOnResponse" in the response.onLoad.      
     // so when the onLoad is triggered this function runs and the data is handled by flash how you set it up.      
     response.onLoad = doThisOnResponse;      
     
     //finally sendAndLoad to the php script, we need to post the data to our php script.      
     //IMPORTANT , make sure you set the right path to the php file or sle it wont work      
     submittedData.sendAndLoad("http://www.stickitindetroit.com/siid/careTaker.php", response, "post");      
}; 

//this is the function that runs on response, this function makes sure everything is placed in the right places. 
function doThisOnResponse(result) { 
//if the result is true, so if everything went ok and the data has been received, do this:      
     if(result){           
          // place the value from "response.receivedData" into our textbox "responsetxtb"           
          //notice how you just call a variable that was atatched to our response loadVars object.           
          responsetxtb.text = response.receivedData;
		  
		  
          
          // we also made a status check in the php file, this is where the value from that variable comes in and           
          // will be placed in the "statustxtb" textbox.           
          statustxtb.text = response.writeStatus;           
     }else {      //else there went something wrong.      
          trace("everything went wrong...aaghhh..damn this");      
     }; 
}; 

// if we press submit submitDataToTextfile() function is executed an the engine is started. 
submit.onPress = function() { 
     submitDataToTextfile();
	 
};

None

djbdr248

Reply To Post Reply & Quote

Posted at: 10/10/09 01:24 PM

djbdr248 EVIL LEVEL 11

Sign-Up: 08/07/07

Posts: 885

I have tried everything to get this to work.
All I want to do is have users save 5 input text feilds like Name, email, and such to a text file on my server but nothing I try works.

This is a fairly common thing you see everywhere why doesno one know anything about it?

I have tried using this tutorial but I can not get it to save more than one input text.
http://www.video-animation.com/dbase002.
shtml

I am stumped broken and bloody can anyone help?


None

djbdr248

Reply To Post Reply & Quote

Posted at: 10/11/09 03:45 PM

djbdr248 EVIL LEVEL 11

Sign-Up: 08/07/07

Posts: 885

Has anyone had to save input text feilds b4?


None

djbdr248

Reply To Post Reply & Quote

Posted at: 10/11/09 11:32 PM

djbdr248 EVIL LEVEL 11

Sign-Up: 08/07/07

Posts: 885

Realy... no one has done this b4... Realy...?


None

Reed

Reply To Post Reply & Quote

Posted at: 10/11/09 11:41 PM

Reed FAB LEVEL 18

Sign-Up: 03/25/04

Posts: 3,867

At 10/10/09 01:24 PM, djbdr248 wrote: All I want to do is have users save 5 input text feilds like Name, email, and such to a text file on my server but nothing I try works.

could you just add them all together like
maintext = emailtext+nametext+etctext;
and then send the maintext? And then if you needed to sort them somehow you could do that with php

although i bet you can send more than one, it would be silly if you couldnt


All times are Eastern Standard Time (GMT -5) | Current Time: 05:36 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!