Computing.Net > Forums > Web Development > image hit counter

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

image hit counter

Reply to Message Icon

Name: BigShow
Date: May 27, 2008 at 22:18:51 Pacific
OS: xp
CPU/Ram: pentium 4
Product: dell
Comment:

Hey guys, I had someone tell me today that they put a counter on their social network page, I find this hard to believe because most of these pages have javascript or php shut off. He says that it is an image that has a url on it pointing to the site the image is hosted at. I dont believe this is true but wanted to see if someone here heard of this and if thay have how could i go abouts making the script?



Sponsored Link
Ads by Google

Response Number 1
Name: Michael J (by mjdamato)
Date: May 28, 2008 at 01:54:11 Pacific
Reply:

Simple create the image link on the page something like this (added spaces so code wouldn't be interpreted by forum):

[img src="ht tp://ww w.yoursite.com/imagecounter.php"]

Then create the page something like this

<?php

//Add code here to count the
//hit and save to db or file

//Display the image
header('Location: myimage.jpg');

?>

Alternatively you could have the code dynamically CREATE an image for the counter and show that.
http://www.phpjunkyard.com/php-grap...

Michael J


0

Response Number 2
Name: BigShow
Date: May 28, 2008 at 07:32:55 Pacific
Reply:

BUt wouldn't that only work if someone clicked the image. I need it to automatically count everytime the page is loaded. Remember, none of these social networks allow javascript or php to run freely, it is limited at best.


0

Response Number 3
Name: Michael J (by mjdamato)
Date: May 28, 2008 at 16:36:12 Pacific
Reply:

No, there is no "onclick" parameter in that image tag. When the HTML page loads and sees the img tag the user's browser will attempt to load the image from the location specified in the src attribute. That will trigger the PHP page that will first perform the "counter" fuction before providing the image to the user.

The link I provided should have everything you need.

Michael J


0

Response Number 4
Name: BigShow
Date: May 28, 2008 at 19:50:53 Pacific
Reply:

Alright, so i understand how to do the counter. The site that you linked to talks about using javascript, i cant use any script on the page. None the less i can do the counter but what if i wanted to do a unique count, how could i achieve this?


0

Response Number 5
Name: Michael J (by mjdamato)
Date: May 28, 2008 at 20:49:41 Pacific
Reply:

What do you mena by a "unique" count? Unique per visitor? You could try IP address, but that won't be accurate since multiple users would be using the same IP address if on a private network behind a router.

Michael J


0

Related Posts

See More



Response Number 6
Name: BigShow
Date: May 28, 2008 at 22:27:59 Pacific
Reply:

a unique visit would be based on someone visiting the site in the same day. basically i want to make it so that if a visitor visits the site within a 24 hour period it only counts as one visit, this helps see how many different peple visit in a day. Nothing would truly be accurate unless scripting was completely allowed. How could i grab an ip address with the image link?


0

Response Number 7
Name: Michael J (by mjdamato)
Date: May 29, 2008 at 00:54:38 Pacific
Reply:

Nothing would truly be accurate unless scripting was completely allowed. How could i grab an ip address with the image link?

But, as I just displayed above you can use scripting. Simply use an image tag and make the src of that tag point to a PHP page on your server. That page can do whatever scripting you want to do and ultimately return an image to the browser.

I don't know how to put it more simply than the fact that the src of an image tag can be anything - including the url to a php page. The browser will attempt to load that source. In the case of php you can do whatever processing you want, but only return an image resource so the user has no knowledge of what happened.

Now that's not to say that whatever site you are referring to does not try and block that, but it may not.

This is nothing different than many SPAM HTML emails that use images to track which emails are opened by users. The email contains an image with a link such as somepage.php?user=dummy@domain.com

When the user opens their email the application will try to load the image. The identifyer on the url tells the receiving page who opened the email and they then know the email is valid. That is why so many email applications no longer load images by default.

Michael J


0

Response Number 8
Name: BigShow
Date: May 29, 2008 at 07:38:52 Pacific
Reply:

I understand completely now, thanks Michael.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: image hit counter

Web/Hit Counter www.computing.net/answers/webdevel/webhit-counter/2607.html

Hit counters for a web site www.computing.net/answers/webdevel/hit-counters-for-a-web-site/1711.html

FREE Hit Counter www.computing.net/answers/webdevel/free-hit-counter/1290.html