Although I agree with Twey, MySQL is a much safer and a better way to go, but here is a script I've put together for you.
PHP Code:
<?php
if(isset($_POST['submit'])){
$path = 'path_to_file/file.txt';
$content = $_POST['content'];
if(file_exists($path)) {
$file = fopen("$path", "w");
fwrite($file, '' . $_POST['content'] . '');
fclose($file);
echo 'Your file has been updated.<br>';
}
if(!file_exists($path)) {
echo 'Unable to update';
}
}
else
{
$filename = 'file.txt';
?>
<form method=POST action="">
<textarea name=content cols=56 rows=20>
<?php
$fd=fopen($filename,"rb");
$cts=fread($fd,filesize($filename));
fclose($fd);
/*prepare file*/
$cts=str_replace(chr(92).chr(34),chr(34),$cts);
$cts=str_replace(chr(92).chr(39),chr(39),$cts);
$cts=str_replace(chr(92).chr(92),chr(92),$cts);
echo htmlspecialchars($cts);
?>
</textarea>
<input type=submit name=submit class=combtn value='Save'>
</form>
<?php
}
?>
Hope this is what you are after.
Smithster.
Bookmarks