I have a form on a website that a when a user submits will store their form details and then write it to a new line in an existing csv file. I have got the code working correctly, allowed all permissions, and tested to see if the file exists (as you can see in my code) but it still doesn't store the information in the csv file.
Here is my code:
if(isset($_POST['cancelForm'])) {
$spreadsheetRecord = array(
$_POST['name'],
$_POST['phoneNumber'],
$_POST['emailAddress'],
$_POST['club'],
$_POST['membership'],
$_POST['reason'],
$_POST['notes'],
$_POST['standardEquipment'],
$_POST['cleanliness'],
$_POST['staffSupport'],
$_POST['valueForMoney']
);
$url = "leavers.csv";
if (!file_exists($url)) {
die('File does not exist');
}
clearstatcache();
$fp = fopen('leavers.csv', 'w') or die("can't open file");
fputcsv($fp, $spreadsheetRecord);
fclose($fp);
I have been struggling for the last few hours to get this (basic!) code to work correctly but it just doesn't seem to want to save. Does anybody have any ideas why this may happening?
Thanks