About visitor statistics

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zakaria84
Forum Newbie
Posts: 8
Joined: Wed Aug 12, 2009 4:13 pm

About visitor statistics

Post by zakaria84 »

Hi everybody,

i'm developping a mini social website that allows to the users to create their
public web page.
After creation, their public webpage can be seen at http://www.mywebsite.com/user=username.
And of course, the user "username" can access to his profil and modify his information.

What i want to do is to give to the user the possibility to see who visited his public
website (http://www.mywebsite.com/user=username).

How can i do that?

Thanks by advance.

Regards.
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: About visitor statistics

Post by yacahuma »

maybe the user could include a little javascript code as part of their site.
zakaria84
Forum Newbie
Posts: 8
Joined: Wed Aug 12, 2009 4:13 pm

Re: About visitor statistics

Post by zakaria84 »

Thanks for your reply,

what will do this javascript code?

Regards.
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: About visitor statistics

Post by yacahuma »

you can also makes them add a hidden frame

Code: Select all

 
<iframe id="RSIFrame"
  name="RSIFrame"
  style="width:0px; height:0px; border: 0px"
  src="http://mainserver/visitcounter.php?user=XXX"></iframe>
 
visitcountrer.php
//very simplistic aproach

Code: Select all

 
$user  = some_validating_function($_GET['user']);
$sql= "update visits set counter = counter+1 where $user";
//execute sql;
 
zakaria84
Forum Newbie
Posts: 8
Joined: Wed Aug 12, 2009 4:13 pm

Re: About visitor statistics

Post by zakaria84 »

Okey,

don't you know where can I find some functions that get user IP and then geolocalize him?
AlanG
Forum Contributor
Posts: 136
Joined: Wed Jun 10, 2009 1:03 am

Re: About visitor statistics

Post by AlanG »

How are you letting them edit their webpage? If you have some sort of panel set up, you should parse the page for them. Will make it far more secure (if done right) and will give you far more control.

The code below will print out a visitor's IP address.

Code: Select all

 
<?php
    echo $_SERVER['REMOTE_ADDR'];
?>
 
zakaria84
Forum Newbie
Posts: 8
Joined: Wed Aug 12, 2009 4:13 pm

Re: About visitor statistics

Post by zakaria84 »

Thank you,

but, is there some libs containing some functions that can handle visitor statistics?

Regards.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: About visitor statistics

Post by John Cartwright »

There is a ton of traffic analysis software out there, but probably nothing with your fine grained requirements. What you want is quite simple to do, actually. Give it a shot!
Post Reply