The short answer is to write the data to a file.
To do this, you need to specify what file to open, open it, write the data and then close it. The functions are pretty straightforward.
fopen()
fputs()
fclose()
<?
$text = "This is my text";
$filename = "textfile.txt";
$file = fopen($filename, "w");
fputs($file, $text);
fclose($file);
?>
This simple example will write the text string to the file specified. You need to make sure that the user writing to the file has permissions to do so. You will need to look at how to append to files as well as some of the other file functions.
http://www.php.net/manual/en/ref.filesystem.php