I am designing a website by using PHP script. As per design demand I need to retrieve the current computer user information who is browsing the site. Can someone help me to provide me the script PHP for computer user information to retrieve?
Required Code of PHP to retrieve computer user information
I can provide you a sample code if you specifically ask what information about the user you want to retrieve. Basically you should be interested in retrieving below information from your website visitor.
IP address, Operating system, Browser type or version
<?PHP
$ipaddress =$_SERVER["REMOTE_ADDR"];
$agent =$_SERVER['HTTP_USER_AGENT'];
if(preg_match('/Linux/',$agent))$os ='Linux';
elseif(preg_match('/Win/',$agent))$os ='Windows';
elseif(preg_match('/Mac/',$agent))$os ='Mac';
else $os ='Not Detected';
if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
$browser = 'Internet Explorer';
elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== FALSE)
$browser = 'Mozilla Firefox';
elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== FALSE)
$browser = 'Google Chrome';
else
$browser = 'Not Detected';
Echo"Your IP is $ipaddress!" + “<br/>”;
Echo"Your Operating System is $os!" + “<br/>”;
Echo"Your Browser is $browser!";
?>
The above code will detect user IP address, Operating system and browser. You can customize the code validate more operating systems and browsers.