3

For getting the mac ID am using the following code.

<?php

ob_start(); // Turn on output buffering
system('ipconfig /all'); //Execute external program to display output
$mycom=ob_get_contents(); // Capture the output into a variable
ob_clean(); // Clean (erase) the output buffer

$findme = "Physical";
$pmac = strpos($mycom, $findme); // Find the position of Physical text
$mac=substr($mycom,($pmac+36),17); // Get Physical Address

echo $mac;
?>

But its returns the server mechines MAC ID.. i need to get the MAC iD of the PC in which my webpage runs.

Can anyone help me

AGK
  • 99
  • 1
  • 4
  • 12

4 Answers4

0

MAC Addresses are not sent in PHP request headers so you will not be able to access it via that means.

Aydin Hassan
  • 1,586
  • 2
  • 19
  • 40
0

You would need to implement the use of JAVA (NOT Javascript) to get the users connection information.

All internet connecting and networking devices have MAC ID's this is to identify the device, the manufacturer and the device number.

This would rely on JAVA being implemented to run on the users machine and would be the most reliable way of gathering that information.

Mark Giblin
  • 928
  • 2
  • 12
  • 19
-1

You can't do this in php. Php only ever runs in your server. The only code you can execute on the client machine is JavaScript.

More info here: How to get Client Machine's Mac Address in a Web application

Community
  • 1
  • 1
SteveP
  • 18,091
  • 8
  • 44
  • 60
  • PHP can be installed as a standalone service without any other services like web server. As long as you can get via remote methods like through an SSH type connection the output from an ipconfig call, you can scrape the MAC ID of the users network device that way but it does need the remote machine being configured to allow it and have the services to do it. – Mark Giblin Jul 14 '16 at 19:50
-1

For a correct solution using PHP + netstat, see How can I get the MAC and the IP address of a connected client in PHP?

This question is outdated, but as I managed to find it and all other responses are stupid, let it be known that you don't need to use Java and even though this information is not directly exposed to php scripts, it's available for every tcp connection in one way or another.

Note that you're unlikely to get client real mac or ip address for that matter, if he's behind NAT (which is likely to be the case for most of your users). So usefulness of it is another thing.

Community
  • 1
  • 1
Paweł Sroka
  • 429
  • 2
  • 10