How to write form data to file?

Hello!
I have the following question: is there a website, or rather a template to bootstrap
It has a get started button, pressing which opens the registration form. I need the data entered in a form recorded in a text file (or csv)
For this, the code page is the form attributed action="func.php"
In func.php:
$source = $_POST['email'];
$file = "file.txt";
$Saved_File = fopen($file, 'a+');
fwrite($Saved_File, $source);
fclose($Saved_File);
?>

But nothing is working + I can not understand how to make closing the window after pressing the button.
If anything, the address at which the page is located 188.226.157.111

Thank you for your help!
September 26th 19 at 11:38
2 answers
September 26th 19 at 11:40
Solution
September 26th 19 at 11:42
file_put_contents('file.json', json_encode($_POST));

Find more questions by tags PHP