This is the script that I've created. You refer to a file as ...?id=1,2,3 and so on...
<?php
$host = "localhost";
$user = "root";
$pass = "";
$db = "downloads";
if(isset($id))
{
if(empty($id))
{
print "You must specify a file";
}
else
{
$connect = mysql_connect($host,$user,$pass);
if(!$connect)
die(mysql_error());
$select = mysql_select_db($db);
if(!$select)
die(mysql_error());
$get = mysql_query("SELECT * FROM downloads WHERE id='$id'");
if(!$get)
die(mysql_error());
$row = mysql_fetch_assoc($get);
if(!$row)
die(mysql_error());
$row[clicks]++;
$add = mysql_query("UPDATE downloads SET clicks='$row[clicks]' WHERE id='$id'");
if(!$add)
die(mysql_error());
$close = mysql_close($connect);
header("Location: $row[link]");
}
}
else
{
print "You must specify a file";
}
?>