I wish I was an Oscar winner
Posts: 86
247 credits Members referred : 0
« on: Sep 01, 2005, 12:08:19 PM »
I would like to create a script that will be able to track downloads from my page. eg. the user clicks to a link to download.php?id=1 and the script gives the file that haves id 1 in a mysql database, and counts the hit.
Is there any script capable to do this?
I am a metal monkey!
Administrator Community Supporter?
Jedai Sword Master
Gender:
Posts: 7975
40807 credits Members referred : 3
« Reply #1 on: Sep 01, 2005, 12:22:06 PM »
Well here is your script :
Code:
<?php
//Avoid fake hits
if ( ! isset($id) ) { exit; }
//This $db stuff can be changed to whatever you use for integration with mySql
/* Table structure :
id -> id of download file -> filename with path hits -> how many times downloaded
*/
$db = new DB_Class(); $db->query("SELECT file FROM downloads WHERE id = '$id' LIMIT 1"); $db->next(); $URL = $db->Record[0];
$db->query("UPDATE LOW_PRIORITY downloads SET hits = hits + 1 WHERE id = '$id' LIMIT 1");
Novice Spammer
Posts: 100
103 credits Members referred : 0
« Reply #4 on: Sep 08, 2005, 07:36:38 AM »
What that script does is store the count in a database. It takes the count amount from database, adds 1 to the number of hits, and then stores it back into the database. (Just explaining to people who dont understand how it works)
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=76