I am trying to get the mac address on LAN connected machine but I have got the following error,
Connected successfullyNo mac address for 127.0.0.1 not found
What I have tried:
I have tried this code,
<?php
$link = mysqli_connect('localhost', 'mysql_user', '');
if (!$link)
{
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysqli_close($link);
$ip = $_SERVER['REMOTE_ADDR'];
$mac = shell_exec('arp -a'. escapeshellarg($ip));
$findme = "Physical";
$pos = strpos($mac, $findme);
$macp = substr($mac,($pos+42),26);
if(empty($mac))
{
die("No mac address for $ip not found");
}
echo "mac address for $ip: $macp";
?>