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:
Button code: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); }
PHP:Code:on (release) { _root.nameData = textField1.text; _root.emailData = textField2.text; _root.saveText(); //function that does sendAndLoad for vars. }
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!"); } ?>


Reply With Quote