<?php $filename = 'test.txt'; $somecontent = $_POST['text']; if (!$_POST['do']) { $array=file($filename); foreach($array as $somecontent){} }else{ $handle = fopen($filename, 'a'); fwrite($handle, $somecontent); fclose($handle); } ?> <form action="" method=post> <textarea name="text" rows=5 cols=20 wrap="off"><?=$somecontent?></textarea> <br><input type=submit name="do" value=хранить> </rorm>
<?php $script_charset = 'windows-1251'; $file = './note.txt'; if ( isset($_POST['text']) ) { $text = (string)@$_POST['text']; file_put_contents($file,$text); } else $text = @file_get_contents($file); ?> <!doctype html> <html> <head> </head> <body> <form method="POST" action=""> <textarea cols="45" rows="15" name="text"><?php echo htmlspecialchars($text); ?></textarea> <br><input type="submit" value="сохранить"> </form> </body> </html>