If we have the following
<form method="post" action="">
<input type="hidden" name="token" value="1">
<input type="submit">
</form>
<?php
if(isset($_POST['token']))
{
$v = 'NAME,COLOR
jack,blue
ivan,gold';
header("Content-Type: text/csv");
header("Content-Disposition: attachment; filename=\"file.csv\"");
header('Expires: ' . gmdate('D, d M Y H:i:s', gmmktime() - 3600) . ' GMT');
//header("Content-Length: " . filesize($path));
echo $v;
}
When I run the script, the browser prompts me to download, when the file is downloaded and I check the contents, it also contains the HTML(above the $v data) markup in the file.
I wish to have a file consisting of just the $v variable data.