<?php
$file = "notepad.txt"; // The .txt file we created above
if($_GET['action'] == "edit") {
$fh = fopen($file, 'w') or die("can't open file"); // Open the file with w (Write) permission.
fwrite($fh,stripslashes($_POST['edit'])); // Write the contents of the textarea to the file.
fclose($fh); // Close the file as we have finished editing it
}
echo "<form method='post' action='notepad.php?action=edit'><textarea cols='60' rows='20' name='edit'>";
$fh = fopen($file, 'r'); // Open the .txt file using fopen
echo fread($fh, filesize($file)); // Output the contents of the text file
fclose($fh); // Close the file as we have finished with it
echo "</textarea><br><input type='submit' value='Update'></form>";
?>