[Solved] Count Downloads?

20 posts Page 2 of 2
Contributors
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Count Downloads?
Dummy1912
mandai wrote:
You could use a server side PHP script to keep track of the downloads, then you can use a meta tag to redirect to the file:
Code: Select all
<meta http-equiv="refresh" content="2; url=file.zip">
<?php

$count = file_get_contents("counter.txt") or die("could not read counter.txt");
echo $count . " downloads so far";
$count++;
file_put_contents("counter.txt", $count) or die("could not write counter.txt");

?>
Hi mandai,

hmmm so how do i use this in my php because theres already a code
should i pm you? so you can change it or whats wrong with it
i know it works when i press the download
but i can't show it in to the current label : Downloaded: ?

thanks
Dummy1912
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Count Downloads?
mandai
If you are only interested in getting the value you should download the counter.txt file directly.
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Count Downloads?
Dummy1912
sorry mandai
but i must sound like a idiot because i don't get it what you are talking about?

i only need to read the value from all the downloads and show them in a label
in the current .html page.

cryer; didn't know this gonna be so difficult


Dummy1912
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Count Downloads?
mandai
This PHP script will show the download count on the current page, as long as your server supports PHP. When you say label what HTML tag are you talking about?
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Count Downloads?
Dummy1912
mandai wrote:
This PHP script will show the download count on the current page, as long as your server supports PHP. When you say label what HTML tag are you talking about?
like the image :D
You do not have the required permissions to view the files attached to this post.
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Count Downloads?
mandai
You just need to put the PHP script in that area of the document body.
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Count Downloads?
Dummy1912
mandai wrote:
You just need to put the PHP script in that area of the document body.
:? seems not really to work :(
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
mikethedj4
VIP - Site Partner
VIP - Site Partner
Posts: 2592
Joined: Thu Mar 25, 2010 4:36 am

Re: Count Downloads?
mikethedj4
You could do this in JS.

Here's a simple script, but I didn't add the cookie option so it'll revert back to 0 on page is reloaded, or visited. Just each time you press the "Download" button it'll add 1 to the counter.

I'm sure you guys can add onto this, but it's something simple, and maybe will help others.
Code: Select all
<html>
<head>
<title>Download Counter</title>
<script type="text/javascript">
function counter(field) {
	field.value = Number(field.value) + 1;
}
</script>
</head>
<body>
	<form name="downloadcounter">
		<input type="button" value="Download" onclick="counter(downloads);">
		<input type="text" name="downloads" value="0" size="5" style="border:0px;">
	</form>
</body>
</html>
If you wanna learn how to add cookies, and such look here.

However if you want to write a hitcounter that records hits from any and all users; you cannot use Javascript - it can't write data to anywhere except cookies, which are unique to each user's browser.

So, you'll have to use some serverside application/script/method to record data permanantly at your server.
[source]

So you're better off using PHP, or Ajax for this.
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Count Downloads?
Dummy1912
oops
Last edited by Dummy1912 on Sun Jul 17, 2011 10:41 am, edited 1 time in total.
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: [Solved] Count Downloads?
Dummy1912
Hello guys,

Sorry i can't lock this topic :(
don't have the function anymore i see cryer;

but thanks to you all
i have found it :D


thanks offc to mikethedj4
for the links i have visit and find the right thing clapper;


thanks guys.

Dummy1912

p.s

Codenstuff please can you lock this topic?
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
20 posts Page 2 of 2
Return to “Help & Support”