use php to produce a text file from the browser

A

Anonymous

Guest
here is a code i use.

//Name the the variable of $text is what you put in the form field called "totext".

$text = $_POST["totext"]

//Define what is to be sent to the text file

$topost = "<p>$text</p>"

//Send it to the text file.

$fp5 = fopen("textfile.txt", 'w');
fwrite($fp5, $topost);
fclose($fp5);

the w means to write to the file, this over writes anything in there. to make it add to the bottom, change the w to a.

you have to be careful with php characters also, with things like " and / and '.
 
Back
Top