homer.favenir Posted October 8, 2009 Share Posted October 8, 2009 hi, ive been searching all day in the internet on how to get the computer name of a client. but im a failure , so i drop by here to ask php professionals. how can i get the client's computer name? TIA Quote Link to comment https://forums.phpfreaks.com/topic/176927-get-computer-name/ Share on other sites More sharing options...
ILMV Posted October 8, 2009 Share Posted October 8, 2009 You can't, I'm pretty sure the only thing you can get with PHP is the IP for that, and that is going to be supplied by their ISP and can be spoofed, you might be able to with JavaScript though. Quote Link to comment https://forums.phpfreaks.com/topic/176927-get-computer-name/#findComment-932842 Share on other sites More sharing options...
Garethp Posted October 8, 2009 Share Posted October 8, 2009 Google, my dear friend (You can just email me some chocolate if you like) $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']); echo $hostname; Quote Link to comment https://forums.phpfreaks.com/topic/176927-get-computer-name/#findComment-932844 Share on other sites More sharing options...
MadTechie Posted October 8, 2009 Share Posted October 8, 2009 That's a client side request. If you try via PHP you probably need an external program. (an external program will probably hit the router) you will need to use a client side script like Javascript, VBS etc however its classed as a security risk to the client, here's a VBS example (untested) try{ var x = new ActiveXObject("WScript.Network"); document.write('Computer: ' + x.ComputerName + '<br />'); }catch (e){ document.write('Permission to access computer name is denied' + '<br />'); } But your need the clients to add the site to the trusted zone in IE (won't work in other browser) or your just get a permission denied error Tools -> Internet Options -> Security tab -> Trusted sites Zone -> Sites... and Initialize and script ActiveX controls not marked as safe Google, my dear friend (You can just email me some chocolate if you like) $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']); echo $hostname; That's the hostname not the computer name! EDIT: updated script Quote Link to comment https://forums.phpfreaks.com/topic/176927-get-computer-name/#findComment-932847 Share on other sites More sharing options...
Garethp Posted October 8, 2009 Share Posted October 8, 2009 GAH! Sorry! When I tested it, I tested it on my local computer, forgetting that the server and client would then share the same name *Shame* Quote Link to comment https://forums.phpfreaks.com/topic/176927-get-computer-name/#findComment-932848 Share on other sites More sharing options...
homer.favenir Posted October 8, 2009 Author Share Posted October 8, 2009 $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']); echo $hostname; it is just getting name of the server and not the client. Quote Link to comment https://forums.phpfreaks.com/topic/176927-get-computer-name/#findComment-932849 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.