-1

It was working on my localhost. But not working on my server. What's is wrong? How to get mac address from windows system using php?

$MAC = exec('getmac');
$MAC = strok($MAC, ' ');
echo $MAC;
jones
  • 749
  • 7
  • 34
  • 3
    Possible duplicate of [How can I get the MAC and the IP address of a connected client in PHP?](https://stackoverflow.com/questions/1420381/how-can-i-get-the-mac-and-the-ip-address-of-a-connected-client-in-php) – Margon Sep 24 '19 at 09:50
  • What error do you get? Does your server run on Windows? – brombeer Sep 24 '19 at 09:52

1 Answers1

0

You'll not be able to get client's MAC address using php, not even using javascript, if user is using windows and user allows you to install an ActiveX control.

http://www.eggheadcafe.com/community/aspnet/3/10054371/how-to-get-client-mac-address.aspx

http://codingresource.blogspot.com/2010/02/get-client-mac-address-ip-address-using.html

Or you can try following

cho GetMAC();

function GetMAC(){
    ob_start();
    system('getmac');
    $Content = ob_get_contents();
    ob_clean();
    return substr($Content, strpos($Content,'\\')-20, 17);
}
Mohit Rathod
  • 1,057
  • 1
  • 19
  • 33