A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: php/flash mailing list (solution should be easy)

  1. #1
    Member
    Join Date
    Feb 2002
    Location
    Detroit
    Posts
    51

    php/flash mailing list (solution should be easy)

    I am using a mailing list that works great. The php writes to a text file on my server and im able to open the text file and read the submitted content.

    HOWEVER, Everytime I submit content, the php just replaces/rewrites info in the text file instead of adding to it. The solution should be rather easy but I cant find it anywhere.

    Actionscript:
    Code:
    function saveText() {
    	// create your VAR OBJECT
    	sendText = new LoadVars();
    	
        // Format variables for PHP
    	sendText.nameData = "&nameData="+_root.nameData;
    	sendText.emailData = "&emailData="+_root.emailData;
    	sendText.newFileName = "text1.txt";
    	
        //tell our script what to do WHEN/IF everything goes ok.
    	sendText.onLoad = function(success) {
    		if (success) {
    			//response is the variableName echo'd in the PHP file. 
    			_root.saveResponse = sendText.response;
    			_root.response_txt.text = sendText.response
    		}
        };        
        //finally call the PHP the script
    	sendText.sendAndLoad("savedData/saveMyText.php", sendText, POST);
    }
    Button code:
    Code:
    on (release) {
    	_root.nameData = textField1.text;
    	_root.emailData = textField2.text;
    	_root.saveText(); //function that does sendAndLoad for vars.
    }
    PHP:
    Code:
    <?php
    
    $newFileName=$_POST["newFileName"];  //Folder HAS to have CHMOD permissions of 777
    
    $nameData=$_POST["nameData"];
    
    $fp = fopen ("text1", "w");
    
    if($fp)
    {  fwrite($fp,stripslashes("$nameData\n$emailData"));  // check to see if open was ok.
       fclose($fp);
       echo ("&response=Successfully!");
    } else {
    echo ("&response=Unsuccessfully!");
    }
    
    ?>

  2. #2
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    in the php it is as simple as
    $fp = fopen ("text1", "a");

    Depending on how you want to use this, it might be better to change the flash to omit these parts "&nameData="+ and perhaps find a different layout for the text file too. In any case, you cannot really read it back into flash with multiple "&nameData=" entries ... you would only get the last

    Musicman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center