I am trying to get a feedback form to write the survey responses from the HTML form into a .csv file to my directory, using PHP. The directory already has permissions to be written to, from a website. However, the file still won't write to the .csv file. I have checked and the data is being stored in the array, but it won't write into the .csv file. Here is the PHP code:
<?php
$understand = $_POST["understand"];
$helpful = $_POST["helpful"];
$rank = $_POST["rank"];
$list = array($understand, $helpful, $rank);
echo $list;
echo '<pre>'; print_r($list); echo '</pre>';
var_dump($list);
$file = fopen("/survey-answers/mylist.csv","a");
if(!$file) echo("<pre>Can't open file </pre>");
foreach ($list as $line) {
fputcsv($file,explode(',',$line)); }
fclose($file);
?>