Hi there, this is suprisingly easy. The functions you're going to want to look at are fopen, fwrite, and fclose. I would suggest you read these, it's handy knowing exactly how they work 😉
What you'll need to do is this:
if(!empty($_POST)) {
/* Create the string you wish to add to the file
(If you're on windows, you could use \r\n at the end of the string
for the new line if you wanted, but not required. */
$sNewLine = $_POST['name'].",".$_POST['phone'].",".$_POST['address']."\n";
/* Open the file for writing (a is for append) and assign a file pointer to a
variable. If you want to read from it too, you could use "a+" */
$fp = fopen("/path/to/file", "a");
// Write your new line to the file
fwrite($fp, $sNewLine);
// Close the file pointer
fclose($fp);
echo "Data added to file, Yay!";
} else {
// Display your form
}
Hope that helps!
Matt