How to get MAC address of client using PHP?
You can get the client's MAC address in javascript, if they are running Windows and allow 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
How to get client MAC address when visit to my website?
Normally it is not possible for security issue. Because MAC address is your machine address and your server can not able to access your machine. The MAC address is not broadcast beyond the LAN the device is connected to - it never leaves the router and passes to the server.
PHP: Get client MAC address
There is no way, the MAC is not included in the TCP/IP stack and once routed, the client MAC is not visible.
MAC = Layer 2
-- edit:
But if it is your app protocol, you can build it in yourself. Put the client MAC into your communication.
Get MAC address from client's machine
Ah, the old exec()
vs shell_exec()
vs passthru()
question.
To see what command is actually being run, and what the system is actually returning, use exec()
, and pass it an int
and an array
as its 2nd and 3rd params respectively, then var_dump()
them both after running the command.
For example:
$cmd = "arp -a " . $ip;
$status = 0;
$return = [];
exec($cmd, $return, $status);
var_dump($status, $return);
die;
If everything went OK, then $status
should be zero and $return
may or may not be empty. However if $status
is non-zero then pay attention to what the value of $return
is, as this will be what your system is telling you is happening when it tries to run your command.
Protip: Pass exec()
the full path to arp
as-in:
#> which arp
/usr/sbin/arp
$cmd = "/usr/sbin/arp -a" . $ip;
Also, bear in mind, depending on where the command is being run, REMOTE_ADDR
may not return anything useful. There are several other ways of obtaining an IP address, which are especially useful if the IP address you need is behind some sort of proxy.
Related Topics
Php 7 With Phpmyadmin Gives Lots of Deprecation Notices
How to Enable the Mysqli Extension in PHP 7
Download a Facebook Video (.Mp4) Via PHP
How to Restrict User from Downloading or Saving Pdf File
Calculate Difference Between 2 Times in Hours in PHP
Laravel Ajax Response Return HTML Elements
How to Get Max and Min Value in a Multidimensional Array
How Would I Skip Optional Arguments in a Function Call
How to Create Cron Job Using PHP
Check If Username and Email Already Exists in Database
How to Create Multi Level Category Hierarchy ( Category Tree ) - Codeigniter
Telegram Bot Api: How to Send a Photo Using PHP
Strip Null Values of Json Object
Saving Multiple Records in a Laravel Eloquent Create
Send File Via Curl from Form Post in PHP
How to Insert Special Character in MySQL Via PHP and Display on HTML Page