Thanks it works, wandered if you can help me with another problem that i am not sure about.
I got this script from php.net it writes new content from a form to the text file that i want to display in the textarea, but because i have a few txt files that are displayed and a few pages i need the script to know which $_post[] it is recieving and what txt file to write to.
I thought perhaps i could put the $filename and $somecontent into an array and use switch statement to determin where to write the information, but i just dont know how to start, i tryed to modify it but i just come up with loads of errors!
would be really greatful for some help.
<?php
$filename = 'test.txt', 'file.txt', 'another.txt'; //perhaps in an array
$somecontent = "$_POST['']"; //perhaps in an array
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
// add a switch statement maybe
// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($somecontent) to file ($filename)";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
?>