The following code used in productlist.php
// some code manipulation to generate new values
$filetodownload = 'DoubleClick to run.txt';
$filehandler=fopen($filetodownload,"w");
fwrite($filehandler,$generatedValue);
fclose($filehandler);
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$filetodownload);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($filetodownload));
ob_clean();
flush();
readfile($filetodownload);
header('Location:druglist.php');
After file downloaded page not redirecting to druglist.php page. Page remains at productlist.php page