Basically, the user will be exporting some data to a txt file. That txt file will then download automatically. The download is working fine and is showing the data I want it to. However, the HTML of the actual page is getting appended onto the end of it?
$fh = fopen($filename, 'w');
fwrite($fh, $data);
fclose($fh);
header('Content-disposition: attachment; filename='.$filename);
header('Content-type: text/plain');
readfile($filename);
If there is html after the code above, you may want to
exitafterreadfile($filename)?