I am new to php and trying just to append these two variables that I'm getting from a form on another page to a csv file.
<?php
$email = $_POST['Email_Address'];
$full_name = $_POST['Full_Name'];
$entry = $full_name;
$entry .= ",";
$entry .= $email;
$file = fopen("contacts.csv","w");
fputcsv($file,explode(',',$entry));
fclose($file);
?>
This script does run and the file does get written, but two problems:
It seems to write over the existing file instead of appending.
Clicking submit takes me to a blank page with Url = location of this php script.
The form is in a pop up window and I just want to close that window onclick instead of it taking me somewhere else.
Here's the form:
<form method="post" action="php-forms/subscribeform.php">
<input placeholder="Name" type="text" name="Full_Name" id="Full_Name" required />
<input placeholder="Email" type="email" name="Email_Address" id="Email_Address" required />
<input class="formBtn" type="submit" />
<input class="formBtn" type="reset" />
</form>
There isn't any error that I can see (I enabled errors to check).
How do I accomplish this?