Yes, you can. This is really simple.
The file you want to write to: (call it something.txt)
The file where you write something new to that file:Code:Here it just says some random words, and yeah... this is just for filling out some, hehe.
Code:Over the doctype:
<?php
if (isset($_POST['submit'])) {
$myFile = "something.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = stripslashes($_POST['sf']);
fwrite($fh, $stringData);
fclose($fh);
header('Location: the_file_where_you_want_to_edit_the_textfile.php?a=done');
}
?>
Inside body:
<form action="" method="post">
<textarea name="sf" cols="40" rows="6">
<?php
$myFile = "something.txt";
$fh = fopen($myFile, 'r');
$theData = fgets($fh);
fclose($fh);
echo $theData;
?></textarea>
<br />
<input type="submit" name="submit" value="Edit" />
</form>
<?php
if ($_GET['a'] == 'done') {
echo 'The file was saved and now it says:<br /><br />';
$myFile = "something.txt";
$fh = fopen($myFile, 'r');
$theData = fgets($fh);
fclose($fh);
echo $theData;
}
?>
Remember to change the CHMOD for the txt file to 777 - or don't you have to do that on txt-files?
Tell me if it doesn't work ;)

