When I run this the first time, when there is not test.txt present, it will create the file and write the info from the form into the file.
The second time I run it, it errors out on trying to open the file.
If I manually create the file test.txt it will error out trying to run as well.
It seems like a permission problem but not seeing what is wrong if it can create it in the first place it should be able to open it the second time.
$data = $_POST["email"];
$file = "test.txt";
if (!$file_handle = fopen($file,"ab")) { echo "Cannot open file"; }
if (!fputs($file_handle, $data)) { echo "Cannot write to file"; }
fclose($file_handle);