if(isset($_POST['myNotes'])){ // Write the notes made to text file and allow download.. $file = "fileNotes.txt"; $notes = $_POST['myNotes']; $handle = fopen("fileNotes.txt", "w"); fwrite($handle, $notes); fclose($handle); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename('fileNotes.txt')); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize('fileNotes.txt')); readfile('fileNotes.txt'); exit; } else { $_POST['myNotes'] = ""; } ?>