The following writes to a single text file, but I would like to change it to write to the selected file (file1, file2...so on) so more than one area can be updated. (only one area edited at a time though)
PHP Code:
<?php
$data_file='content.txt';
$changes='';
if(isset($contents)) {
$archive=fopen($data_file,'r+');
flock($archive,2);
ftruncate($archive,0);
fputs($archive,stripslashes($contents));
flock($archive,3);
fclose($archive);
unset($contents);
$changes='<span class="iheadline">Changes made!</span> » <a href="/">View Changes [+]</a><br />';
}
function getfile($filename) {
$fd = fopen($filename, "rb");
$content = fread($fd, filesize($filename));
fclose($fd);
return $content;
}
$data=getfile($data_file);
?>
The idea scenario would be to have a dropdown box with the files listed so you can select the one you want to edit.
PHP Code:
$data_file = array('file1' => 'file1.txt', 'file2' => 'file2.txt', 'file3' => 'file3.txt', 'file34' => 'file4.txt');
I changed $data_file to an array but I'm not sure how it would all tie together to write to the selected file.
Select dropdown can possibly look like this.
Code:
<SELECT name="data_file">
<OPTION value="file1">edit file1</OPTION>
<OPTION value="file2">edit file2</OPTION>
<OPTION value="file3">edit file3</OPTION>
<OPTION value="file4">edit file4</OPTION>
</SELECT>
Any ideas/help would be appreciated. Thank you.
Bookmarks