WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-24-2006, 10:15 AM
DarrenPWS DarrenPWS is offline
WebProWorld Pro
 

Join Date: Jan 2004
Location: Milton Keynes, UK
Posts: 117
DarrenPWS RepRank 0
Default PHP - Get Computer Name

Hi,

Does anyone know how I can get the name of a computer using PHP.

Thanks,

Darren
__________________
Darren Darkins
Reply With Quote
  #2 (permalink)  
Old 05-24-2006, 01:23 PM
speed speed is offline
WebProWorld Veteran
 

Join Date: Aug 2003
Location: Cornwall, UK
Posts: 824
speed RepRank 1
Default

If you're after the name of the host the PHP script is running on you can use $_SERVER['SERVER_NAME'];

If you're after the name of a computer that's connected to the script you can get it's IP from $_SERVER['REMOTE_ADDR'] and gethostbyaddr.

Code:
echo gethostbyaddr('127.0.0.1');
Will return the name of the local host.

If none of those are what you are after then let me know and I'll try again.
__________________
TOLRA Micro Systems Limited US & UK Web Hosting with Continuous Data Protection
Web Directory : Web Directory Script
Reply With Quote
  #3 (permalink)  
Old 05-25-2006, 05:08 AM
DarrenPWS DarrenPWS is offline
WebProWorld Pro
 

Join Date: Jan 2004
Location: Milton Keynes, UK
Posts: 117
DarrenPWS RepRank 0
Default

Hi speed,

thanks for that - I'm probably not making it clear what I need as a lot of people on other forums have offered the same solution.

I'm looking to get the actual name that the user gives the computer, which might be a windows only thing? For example, I have a laptop I call D-LAPTOP.

Hope that makes a bit more sense - it's a bit of a long shot anyway as I guess it isn't the sort of information you should be able to just access.

THanks for your help
Reply With Quote
  #4 (permalink)  
Old 05-25-2006, 05:21 AM
speed speed is offline
WebProWorld Veteran
 

Join Date: Aug 2003
Location: Cornwall, UK
Posts: 824
speed RepRank 1
Default

Ok, I don't use PHP on Windows nor do I have it installed to test this but have you tried reading the environment variable COMPUTERNAME?

getenv('HOSTNAME') should return the host name on Linux.
__________________
TOLRA Micro Systems Limited US & UK Web Hosting with Continuous Data Protection
Web Directory : Web Directory Script
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: computer, name, php



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Search Engine Friendly URLs by vBSEO 3.0.0