Author Topic: [JavaScript / PHP / MySQL] Client machine name  (Read 5955 times)

0 Members and 1 Guest are viewing this topic.

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
I've been writing a fault & equipment database at work, and I discovered a PHP function which effectively runs an NSLookup based on the client's IP address.

The returned hostname is then checked in the database to find out which room the user is posting from, allowing the user to report a fault in their room with a single click, rather than looking for their room from a big drop-down box.

I'll put some sample code up on Tuesday when I get back into work.

The PHP command is:
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);

No good for internet, but great for intranet scripting.
You are our 9001st visitor.
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17412
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: [JavaScript / PHP / MySQL] Client machine name
« Reply #1 on: January 14, 2010 »
I'll see if I can incorporate it somewhere on the portal :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Re: [JavaScript / PHP / MySQL] Client machine name
« Reply #2 on: January 19, 2010 »
Work won't let me paste the source code on the internets for security purposes, but there really isn't much else to it than I have already posted - it's what you do with the returned data that counts.
You are our 9001st visitor.
Challenge Trophies Won: