koolaid Posted October 18, 2007 Share Posted October 18, 2007 Hey guys. I have a little problem. I have php writing flash variabeles to a text doc. This works great. After it writes the text doc i need flash to pull this text doc and display it, but in order to do that i need to either remove the "_searchKey =" (that's the first line the php writes to the text doc), or put a piece of text before it. Not sure how to do this with this script, but i am sure this is easy for you php wizards. <?php ///my flash variables $_POST["repsName"] . $_POST["clientsName"]. $_POST["clientsPhone"]. $_POST["clientsUrl"]. $_POST["shortDescroption"]. $_POST["longDescription"]; $folder = "./files/".$_POST["clientsName"]."/"; if(!is_dir($folder)) mkdir($folder, 0755); $mode = file_exists($folder.'user_input.txt')?'a':'w'; // append if file exists otherwise create it $fp = fopen($folder.'user_input.txt',$mode); // open file foreach($_POST as $K=>$V) { fwrite($fp, "$K = $V\r\n"); // dump the contents of the $_POST array to the file } fclose($fp); ?> /////this is an example of the text doc that it writes _searchKey = 33022 repsName = matt paxton clientsName = jellybeans clientsPhone = 6107972477 clientsUrl = jellybeans.com shortDescription = short longDescription = long Link to comment https://forums.phpfreaks.com/topic/73796-easy-question-writting-text-doc/ Share on other sites More sharing options...
MmmVomit Posted October 18, 2007 Share Posted October 18, 2007 First, code tags are your friend. Please use them. Here's a quick and dirty solution. <?php ///my flash variables $_POST["repsName"] . $_POST["clientsName"]. $_POST["clientsPhone"]. $_POST["clientsUrl"]. $_POST["shortDescroption"]. $_POST["longDescription"]; $folder = "./files/".$_POST["clientsName"]."/"; if(!is_dir($folder)) mkdir($folder, 0755); $mode = file_exists($folder.'user_input.txt')?'a':'w'; // append if file exists otherwise create it $fp = fopen($folder.'user_input.txt',$mode); // open file foreach($_POST as $K=>$V) { if($K != '_searchKey') { fwrite($fp, "$K = $V\r\n"); // dump the contents of the $_POST array to the file } } fclose($fp); ?> Link to comment https://forums.phpfreaks.com/topic/73796-easy-question-writting-text-doc/#findComment-372354 Share on other sites More sharing options...
MmmVomit Posted October 18, 2007 Share Posted October 18, 2007 Some other problems with your script. What is this line supposed to do? $_POST["repsName"] . $_POST["clientsName"]. $_POST["clientsPhone"]. $_POST["clientsUrl"]. $_POST["shortDescroption"]. $_POST["longDescription"]; Here you potentially give access to any file on your server. Pretend I entere a clientsName of "../../etc". $folder = "./files/".$_POST["clientsName"]."/"; Link to comment https://forums.phpfreaks.com/topic/73796-easy-question-writting-text-doc/#findComment-372356 Share on other sites More sharing options...
koolaid Posted October 18, 2007 Author Share Posted October 18, 2007 Thanks dude. Sorry about the code tags. I am not exactly sure what i was doing with that line of code. I just started trying to learn php about a week ago. I ordered some books online waiting for them now. I appreciate your help! I will give it a shot. Link to comment https://forums.phpfreaks.com/topic/73796-easy-question-writting-text-doc/#findComment-372367 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.