Notice: Undefined variable: s_offline in /homepages/6/d168803796/htdocs/officetrio.com/o3/o3start.php on line 314
Free PHP Download Tracking Script OfficeTrio: The Integrated ECommerce Solution OfficeTrio: The Integrated ECommerce Solution OfficeTrio: Features OfficeTrio: User Manual OfficeTrio: Testimonials OfficeTrio: The Demo is Offline! OfficeTrio: Order O3 Now

Free PHP Download Tracking Script


Database Table:

 CREATE TABLE downloads (
   file VARCHAR(60) NOT NULL,
   counter INT UNSIGNED,
   PRIMARY KEY (file)
   );

Line By Line: dlt.php

  • Create a string containing the header info we'll use to redirect the browser:

      $cm = "Location: $file";
      header ($cm);


  • Connect to the DB

      $db_user = "dbuser";
      $db_passwd = "dbpwd";
      $db_name = "dbname";

      $db = mysql_connect("localhost", $db_user, $db_passwd);
      mysql_select_db($db_name, $db);


  • Update the downloads table - increment the counter for that page.

      mysql_query("UPDATE downloads SET counter=counter+1 WHERE file='$file'",$db);

  • If no row was affected by the last update statement, then there must have been no previous download of this file before, so we just need to add it to the table. We use an INSERT statement to insert the file name and '1' for the number of downloads.

      if (mysql_affected_rows($db) < 1) {
      $result = mysql_query("INSERT INTO downloads VALUES ('$file', 1)", $db); } }


  • The final statement closes the connection to the database.

      mysql_close($db); ?>



Usage...

  • If you want to reset the counter, you just delete the appropriate rows from the database. So to delete the downloads for all files:

      delete from downloads;


  • To use the script you can have a download button by creating a form like this:   <form action="../dlt.php" method="post">
      <input type="hidden" name="file" value="../ex/ebot.zip">
      <input type="submit" value="Download">
      </form>


  • Or you can have a text link to the script by including the parameters in the URL:   <a href="Yourdomain.com/dlt.php?file=ebooks/MYPS!.zip">



To download any script, please go to the Free Scripts page.



Tutorials

Contents

Free EBooks
Free Scripts

Introduction
What Can I Do With A Website?
Internet History
Introduction
Preparation
Website Builders

Webmaster's Tools
Tools Intro
HTML Editor
PHP IDEs
Graphics Resources
Telnet and FTP
Miscellaneous Tools

Web Design
Web Design
Domains
Keywords/Description
Logo/Graphics

Creating Web Pages
Setup
HTML
HTML Tips And Tricks
Home Page
Navigation
Other Pages

Webhosting and Unix
Webhosting
Telnet/Unix
More Unix
Website Upload
Analyse And Verify

Programming
Programming 1
Programming 2

PHP
PHP
PHP Scripts
PHP Hit Counter Script
PHP Download Tracking Script
PHP Navigation Script
PHP Affiliates Tracking Script
PHP Users Management
PHP Site Search Script

Perl
Perl
Perl Hit Counter Script
Perl Order Processing Script

Databases
Databases
SQL
Database Setup

ECommerce
ECommerce

Automation
Automating Order Processing
PayPal Automation
Email Automation
Installing Scripts

Security
Basic Security

Affiliates
Affiliates Programs

Managing Your Website
Website Management
Promotion/Advertising
Search Engines
Search Engine Optimisation



Powered By OfficeTrio