I have my map code in openlayers JS. My input data is in a text file and I am able to render the points on the map. I have to give the user a right to create a layer by entering the data in a form. Writing a program to insert data into a text file is trivial. But I am stuck at how to include this layers code in the JS programmatically so that after giving the layers details in the form if the user reloads the page then the new layer should be visible, Any solutions??
You haven't specified what technology you are using on your server-side (if you have a server-side application). If you are running the app on a Web server, then instead of writing to a file the user-entered data is usually stored in a user session on the Web server.
There are other possible workflows (like using AJAX to increase interactivity), but I guess this is the easiest one.