0

I'm asking if there is a way to get the name, ip and mac of a pc with php or javacript?

I need this to configure a view in an application I developed. In this case, the user uses windows to access my application that is built with the PHP framework, codeignter, and obviously I use PHP to connect with the DB.

Why the name of the PC? Well ! the name of the pc in a network can be replaced with another pc with the same name. With the mac address can't. but its a way i cant get the name, ip and mac of a pc who acces to my aplication i want to know.

Vikdor
  • 23,934
  • 10
  • 61
  • 84
morrisonrox
  • 15
  • 1
  • 3

4 Answers4

1

Getting the MAC address isn't possible without some browser plugin client-side.

Also, you should know that it is very easy to change your MAC address. Besides, not everyone even has one. Ethernet is not a prerequisite for internet access.

You can get the remote address out of $_SERVER data in PHP, but it isn't always the real client IP, in cases of proxying or NAT.

Brad
  • 159,648
  • 54
  • 349
  • 530
1

Impossible with just PHP, JavaScript, and nothing else.

You can get the IP address though, with $_SERVER['REMOTE_ADDR']. Note that if the user uses some kind of IP-hiding software like Hide My IP or such, this won't work either.

For the PC Name and Mac address, as Brad has mentioned, you need a client-side plugin, with another programming language, most likely Java or Flash.

Lucas
  • 16,930
  • 31
  • 110
  • 182
0

Using PHP, you can't get information about the computer specifically, unless it has been input into a form or something like that.

However, if you go to this question, you will find how to learn the name using Javascript.

How can I read the client's machine/computer name from the browser?

Community
  • 1
  • 1
Michael Thompson
  • 541
  • 4
  • 21
0

To get the real IP address you can use this code

<?php
//whether ip is from share internet
if (!empty($_SERVER['HTTP_CLIENT_IP']))   
  {
    $ip_address = $_SERVER['HTTP_CLIENT_IP'];
  }
//whether ip is from proxy
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))  
  {
    $ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
  }
//whether ip is from remote address
else
  {
    $ip_address = $_SERVER['REMOTE_ADDR'];
  }
echo $ip_address;
?>
Soteris 92
  • 41
  • 3