Want To Be A Blogger  →  Start A Blog  →  Increase Traffic  →  Make Money Online  →  Recommended Things

Get Visitor Details Using PHP And HTML

Thursday, Sep 28, 2017

Tags:- PHP HTML


In this tutorial we will show you how to get and display visitor details using PHP and HTML. We get details like visitor ip address, what page visitor current visiting, what webpage visitor come from, what time he visit page and what platform and browser he used to visit our page.You may also like get user location using PHP.


See Demo
Get Visitor Details Using PHP and HTML


To Get Visitor Details It Takes Only One Step:-

  1. Make a PHP file to get visitor details


Step 1.Make a PHP file to get visitor details

We make a PHP file and save it with a name get_details.php

// Database Structure 
CREATE TABLE `visitor_details` (
 `ip` text NOT NULL,
 `current_page` text NOT NULL,
 `referrer` text NOT NULL,
 `time` text NOT NULL,
 `user_agent` text NOT NULL,
 
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=latin1

<html>
<body>
<div id="wrapper">

<div id="detail_div">
<?php
 $ipaddress = $_SERVER['REMOTE_ADDR'];
 $page = "http://".$_SERVER['HTTP_HOST']."".$_SERVER['PHP_SELF'];
 $referrer = $_SERVER['HTTP_REFERER'];
 $datetime = date("F j, Y, g:i a");
 $useragent = $_SERVER['HTTP_USER_AGENT'];

 echo "<p>IP Address : ".$ipaddress."</p>";
 echo "<p>Current Page : ".$page."</p>";
 echo "<p>Referrer : ".$referrer."</p>";
 echo "<p>Current Time : ".$datetime."</p>";
 echo "<p>Browser : ".$useragent."</p>";

 $host="localhost";
 $username="root";
 $password="";
 $databasename="sample";
 $connect=mysql_connect($host,$username,$password);
 $db=mysql_select_db($databasename);
 
 mysql_query("insert into visitor_details values('','$ipaddress','$page','$referrer','$datetime','$useragent')");
 
?>
</div>

</div>
</body>
</html>

In this step we create a database table called 'visitor_details' and add 5 columns to store 5 details of visitor all the functions we use are already predefined by PHP and after getting all the details we store them in our database.You may also like get address, longitude and latitude using PHP.



That's all, this is how to get visitor details using PHP and HTML.You can customize this code further as per your requirement. And please feel free to give comments on this tutorial.

Subscribe Our Newsletter And Get Tutorials And Offers Via Email

About Me


Hello, My Name is Mudit Jain. I am a Web Developer, Professional Blogger and Digital Marketer from India. I am the founder of TalkersCode. I started this blog in february 2015 to help web developers & bloggers by providing easy and best tutorials, articles and offers for web developers and bloggers.