Send variable to text file

I’m looking for a way to send the variable stored in a text field to a textfile on the serevr and save it there.

ie the user enters a name and a number into 2 text fields, this is then sent toa textfile (or xml file, etc) and is storedin there for use later.

Any ideas or links to tutorials?

Sean