I want a user of my website to enter some text in a text area and when he submits the form, the text that he entered be stored in a .txt file that is present in same directo
This one might help you.
http://wcetdesigns.com/tutorials/2012/11/01/edit-save-file.html
https://web.archive.org/web/20131210151034/http://wcetdesigns.com/tutorials/2012/11/01/edit-save-file.html
edit.php, file where users can edit using the textarea tag.
view file
save.php, file where the saving process will take place.
Javascript doesn't have access to file system so you must use some server side language like PHP as in the given example