Get Client IP, Mac Address and User Agent

Here is sample to get Client IP, Mac Address and Browser User Agent

 

<?php

// PHP program to get IP address of client
$IP = $_SERVER[‘REMOTE_ADDR’];

// $IP stores the ip address of client
echo “Client’s IP address is: $IP”;

// Print the ip address of client
Echo(“<br/>”);
// PHP code to get the MAC address of Client
$MAC = exec(‘getmac’);
echo “MAC1 address of client is: $MAC”;
// Storing ‘getmac’ value in $MAC
$MAC = strtok($MAC, ‘ ‘);
Echo(“<br/>”);
// Updating $MAC value using strtok function,
// strtok is used to split the string into tokens
// split character of strtok is defined as a space
// because getmac returns transport name after
// MAC address
echo “MAC address of client is: $MAC”;

Echo(“<br/>”);

echo “UserAgent1”. $_SERVER[‘HTTP_USER_AGENT’];
Echo(“<br/>”);
$browser = get_browser();
echo(“UserAgent2”.$browser);

echo $_SERVER[‘HTTP_USER_AGENT’] . “\n\n”;

$browser = get_browser(null, true);
print_r($browser);
?>

For more, you may visit following link and study more

https://www.php.net/manual/en/function.get-browser.php

Here is one of the good link

https://www.geeksforgeeks.org/how-to-get-the-mac-and-ip-address-of-a-connected-client-in-php/



Leave a Reply

Your email address will not be published. Required fields are marked *