Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting How Many Zip File Downloads

Status
Not open for further replies.

3dColor

Programmer
Jan 10, 2006
240
US

I created a free property management web site template within a zip file that people can download.

I want to dynamically record how many times it has been downloaded.

I understand how to create a DB table and record each time a page has been accessed but I am not sure how to do it when someone clicks on the download button.

Here is what I am thinking.

When the click on they button, instead of linking the button to the zip file I would redirect them to another page that would first enter the click to the database and then redirect them to the zip file.

Would that be the best way to do this?
 
That's how I would do it. Or, you can use ajax to call a page that will write to your dB table:

jquery version:

Code:
<script language="javascript"  type="text/javascript" src="/javascript/jquery-1.3.js"></script>
<script>
$(document).ready(function () {  
$('#loading_image').hide();   

$('#download').click(function() {
	$('#loading_image').show();
	$('#download').hide();
});


// show loading image, as request is about to start
$.ajax({   
	   url: 'saveClick.cfm',   
	   type: 'get',    
	   complete: function() {        
// request is complete, regardless of error or success, so hide image       
	   $('#loading_image').hide(); 
	 },
	  success: function(msg) {
		   $('#response').text(msg);
	   }
	});
});
</script>
</head>

<body>
<form>
<input type="submit" name="submit" value="download" id="download" />
</form>
<div id="loading_image">
<img src="ajax-loader.gif" border="0" /> Loading ...
</div>
<div id="response"></div>

and in your saveClick.cfm, you can use and update query to increment the value of the click.
etc. etc.
ajax version is a bit more of a web2.0 version...
hope it helps


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top