Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

How many downloads

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

How many downloads

Postby macce » Sun Feb 16, 2003 3:31 am

How to made a easy script that tells the downloader how many have alredy downloaded a file?

mail me at:
macce@macce.cjb.net

visit me at:
macce.cjb.net
macce
New php-forum User
New php-forum User
 
Posts: 13
Joined: Fri Feb 07, 2003 10:11 am
Location: Finland

Postby Redcircle » Sun Feb 16, 2003 12:39 pm

What I do is create a table with 3 fields. id,filename, and hits. When I add a file I put the filename into the db and use this function. It uses the $_GET super global from the ULR and increments the hits field and redirects to download the file.

Code: Select all
if(!empty($_GET['file']) && $_GET['file'])
{
        $db =dbConnect();
        $query = 'update filedls set hits = hits +1 where filename = "'.$file.'"';
        mysql_query($query, $db);
        mysql_close();
        header('Location: http://yourdomain.com/files/'.$file);
}
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron