Jump to content

easy question writting text doc


koolaid

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.