Hmmm I tried replacing my code with that but it didn't write to the text file. It brought up the success message but the data wasn't in the text file this is how i put it in...
PHP Code:
$File = "questions.txt";
$Handle = fopen($File, "r+");
$Data = "<p>From:" . $visitor . "<br />Submitted on:" . $todayis . "<br />" . $notes . "</p><hr />";
define('BUFSIZ', 512); // Handle half a kilobyte at a time.
// fcopy(resource $src, resource $dest):
// copy the contents of $src to $dest.
// $src must be readable, and $dest writeable.
function fcopy($src, $dest) {
for (; !feof($src); $buf = fread($src, BUFSIZ))
fwrite($dest, $buf);
}
// file_prepend_contents(string $filename, string $data):
// prepend some data to a file.
function file_prepend_contents($File, $data) {
if ($data === '') return;
// Open the provided filename, and a temporary file.
$f = fopen($File, 'r');
$ft = tmpfile();
// Copy the contents of the file to the temporary file.
fcopy($f, $ft);
// Seek the temporary file (which is in r+ mode) to the beginning,
// and re-open the main file for writing, truncating it.
fclose($f);
fseek($ft, 0);
$f = fopen($File, 'w');
// Write the data to the main file, followed by the original contents.
fwrite($f, $data);
fcopy($ft, $f);
// Close the handles.
fclose($f);
fclose($ft);
}?>
Bookmarks