crj
January 22nd, 2002, 15:59
hi, does anyone know of a php form processing script that adds the data to the end of an already existing txt file?
basically you input data, then the php script adds it to the end of a txt file....
i dont know php but it doesn't sound that hard to do....
<?php
$file_name = "data.txt";
$file_pointer = fopen($file_name, "a");
$lock = flock($file_pointer, LOCK_EX);
// Use 2 if you use < PHP4.0.2
if ($lock) {
fseek($file_pointer, 0, SEEK_END);
// Use this if < PHP4.0RC1 : fseek($file_pointer, filsize($file_name));
fwrite($file_pointer, "what u wanna write");
flock($file_pointer, LOCK_UN);
// Use 3 < PHP4.0.2
}
fclose($file_pointer);
print "data written to file successfuly";
?>
how do i make it so that "what you wanna write" is the data from a text field?
basically you input data, then the php script adds it to the end of a txt file....
i dont know php but it doesn't sound that hard to do....
<?php
$file_name = "data.txt";
$file_pointer = fopen($file_name, "a");
$lock = flock($file_pointer, LOCK_EX);
// Use 2 if you use < PHP4.0.2
if ($lock) {
fseek($file_pointer, 0, SEEK_END);
// Use this if < PHP4.0RC1 : fseek($file_pointer, filsize($file_name));
fwrite($file_pointer, "what u wanna write");
flock($file_pointer, LOCK_UN);
// Use 3 < PHP4.0.2
}
fclose($file_pointer);
print "data written to file successfuly";
?>
how do i make it so that "what you wanna write" is the data from a text field?