How would one go about outputting to a .txt file the results of a query which the user is prompted to download in via the browser? All I want to do is allow the end user to download the results of specific query in a text file to their local computer. (The query being all of their Private Topics, so they can save their private topics off the board.)

My second question is this: Is there a way to do this securely? Is doing something like this inherently insecure?