Wednesday, January 01, 2014

Create Simple Profile Visitors in PHP - learn more @i-vision blog

Today We are living in Profile world. In the real life we would see how many will visit our profile and check our status.But in Profile world how could we know.many were asking about it.Many were using facebook app like Profile visitors and posting some images on their wall.I hope facebook does'nt have the option since it may hinder privacy of visitors. And this app may be to a prank!.so,lets built a Simple PHP based profile visitor for Your cool website in PHP.

Why  track visitors?

your website may have a large amount of visitors day by day! and this stats may help you to increase your confidence and may increase your standard of your website.The main purpose of website is for viewers to display them in websites and generating traffic daily.this can be monitored with the help of stats counter.And if you may built a social networking site ,This cool feature may introduce many fans for Your site.

How Simple We Could Code them?

Creating Profile visitors table in Database is quite easy.The Unique Way of identifying the visitor is getting their Ip address and Timestamp from them and saving the,in PHP how could we get the IP address of the client and Tine when they enter the Site.In addition to this we may have browser list also.which could add more experience for Admin to track the most visited browser and change the settings accordingly!
so, here i'm using:
time() for Timestamp function to note down the time of the user entering Your site.
$_SERVER['REMOTE_ADDR'] for noting down the IP address of the users entering your site.
$_SERVER['HTTP_USER_AGENT']; for noting down the Browser they have used to view your site.

we are going to mix this three variables in PHP

include('config.php'); //connection to database
$ip=$_SERVER['REMOTE_ADDR']; // identifying and saving the clients ip address
$time=time(); //obtaining clients time
$browser=$_SERVER['HTTP_USER_AGENT'];  //getting browser
$s=mysql_query('insert into profile_visitor (ipaddress,time,browser) values ("'.$ip.'","'.$time.'","'.$browser.'")');

here we just Get the variables of IP address and Browser client are obtained. and save it is in Table.

Generate the table accordingly for codings :
1)id -can be primary-11(autoincreament)

thus you can run it in your browser and verify your table.If you're testing it from local host it may be noted as

Now we are going to query the details from table of database as Admin.

include('config.php'); //connection to database
$s=mysql_query('select from profile_visitor order by time desc');
$row = mysql_fetch_array($s);
$i=0;while ($i < $num)
{  ?>
<span id="shivasurya">ip:<?php echo $row['ipaddress']; ?>--time:<?php echo $row['time']; ?>--browser:<?php echo $row['browser']; ?> </span>
}  ?>

the above code generates the visitors time and ipaddress,browser name for admin.

If you are constructing Social Network Or profile based sites you may use Id of the user and the user name for every visits and group them accordingly and visits.
There is no application in facebook that can track the recent visitors.feel free to comment below!


Algorithm Freak, Coder, Web And Android Developer, love to develop Apps for Local Business in my Freetime. For Queries,Quotes Drop me a Mail to


Post a Comment

feel free to post your comments! Don't Spam here! Registered & Protected  Z6HO-DGFO-S2CO-JRZGCopyrights Protected (C)2013-2015 i-visionblog ~ s.shivasurya.

Designed and Maintained by S.Shivasurya | S.Shivasurya