JoshE Posted January 17, 2007 Share Posted January 17, 2007 Hi, will you please help? ::)This is my code...when the 3 database statements are added to this page, the calling page blinks the file download box. Without them I am able to choose if I download or not as I need. How can I get the download box to stay on screen and use a database to keep track of the count of this page being called?I don't want to use global or session level variables!Here's my code:calling statement of "index.php", (final anchor did not display right on this editor) :<a class = "mine" href="http://localhost/download.php" >Mage's Reign of Teror </a>code of page download.php :<?php $filename1 = "phantom.exe"; $filename = 'C:/www/webroot/download/phantom.exe'; $ctype="application/force-download"; if (!file_exists($filename)) { die("NO FILE HERE"); } header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); header("Content-Type: $ctype"); header("Content-Disposition: attachment; filename=\"".$filename1 ."\";"); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".@filesize($filename)); set_time_limit(0); @readfile("$filename") or die("File not found."); tep_db_connect( 'localhost', 'root', '', 'demodownloadscount', 'db_link');tep_db_query("INSERT INTO tab (diddownload, datetime, filename) VALUES ('YES',NOW(), 'MAGE_DEMO')");tep_db_close('db_link'); ?>Thank you, Josh Link to comment https://forums.phpfreaks.com/topic/34613-how-do-i-use-headers-to-download-file-and-insert-in-database-on-same-page/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.