Jump to content

Recommended Posts

hey sup guys, me again with another question, how can i make my own custom page counter, like the one i have up here www.targetincs.com "i dont like it" i can get it for free but it doesnt match up with the template theme, and i would like to either generate a custom one which i can make it the exact color and background, or read a tutorial on how to make one from start to finish in javascript "dont want it in php"

Link to comment
Share on other sites

I'd use the onload event and add to the counter each time a page loads. I 'd want to save the data in a table so I'd do an AJAX call too.

Edited by niche
Link to comment
Share on other sites

i dont want to save it, it should just display it on the page how many time the site was/is visited

Link to comment
Share on other sites

if you want it do it with clients side you can use cookie to store the hits. but cookie goes back and forth with http request. there is another better way to use localstorage. but it is supported only in modern browsers. another way is you can do that in server side. you can append a file which executeon each request and will write and count the hits on somewhere. a flat file would be enough for it. it will works in all case. niche's way will work too untill browser has js enabled. when you use store any data client side its become unsecure. so if it is critical to your application server side solution will be the best.

Link to comment
Share on other sites

if you want it do it with clients side you can use cookie to store the hits.
yes, but that will only track per user. You need some form of persistant storage on the server side for this. Edited by thescientist
Link to comment
Share on other sites

yes, but that will only track per user. You need some form of persistant storage on the server side for this.
exactly. I was not sure OP needs per user page count or total page count so i tried to mention the possible ways. i should have mention that. thanks for pointing out.
Link to comment
Share on other sites

Guest So Called

Sometimes what we want is impossible. The only way to store and update total site visits is on the server, with some kind of server side script. Way before I learned MySQL I used to store hits in a flat file. My PHP script that served the page would open the file, read the current hit count, increment it, then write the new count back to the file. This would be easy to implement even for a PHP novice, and no database or database skills necessary.

Link to comment
Share on other sites

thanks, but i found what i was looking for, sorry it took so long to reply, i totally forgot i made this post, since im hardly in this section, and what the person wanted was this "still dont like it" www.targetincs.com

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...