Hello,
Is there a way using PHP to have the fields of a HTML form be written out to a Microsoft Excel CSV file on the server (as part of the form processing) and then have that Excel/CSV file emailed to someone. Thanks for any feedback.
This may be a start:
<?php
$cr = "\n";
$data = "Name" . ',' . "Email" . ',' . "Age" . ',' "Location". $cr;
$data .= "$name" . ',' . "$email" . ',' . "$age" . ',' "$location". $cr;
$fp = fopen($filename,"a"); // $fp is now the file pointer to file $filename
if($fp)
{
fwrite($fp,$data); // write information to the file
fclose($fp); //close the file
echo "File Saved Successfully"
}
else
{
echo "Error Saving File";
}
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=test.csv");
header("Pragma: no-cache");
header("Expires: 0");
echo $data;
?>