The download link would point to a php file, such as download.php?id=123
-- this file would then take the ID and check the downloads database. If the ID exists, you run a query such as UPDATE files SET downloads = downloads + 1 WHERE id = 123
.
Afterwards, you set the headers using header()
to set content-type. Then use readfile()
.
See How to force file download with PHP on how to set headers and force a download.
Cheers!