You'll have to check up on PHP's handling of text files. Get a tutorial on opening files, writing to it, and so on.
PHP's form handling is very convenient. The html form input item name becomes the variable. For example, you have a form that contains <input type="text" name="field1">, $field1 becomes the variable containing the input data.