if(isset($_POST['btn']) and !empty($_POST['mytext']))
{
$mytext = $_POST['mytext'];
$file=fopen("123.txt", "r+");
fwrite ($file, $mytext);
fclose($file);
}
if(isset($_POST['btn']) and !empty($_POST['mytext']))
{
$mytext = $_POST['mytext'];
file_put_contents('123.txt', PHP_EOL . $mytext, FILE_APPEND);
}