Jump to content


Photo

plz help with gethostbyname()


  • Please log in to reply
5 replies to this topic

#1 tony5429

tony5429
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 04 August 2006 - 02:39 PM

<?php
	$ip = GetHostByName($_SERVER['REMOTE_ADDR']);
?>

^There's the script. I want to get the IP address of the visitor to the page, however, I keep getting the local IP address of the server itself (192.168.3.1). I've used gethostbyname() a million times before on apache with no problem, but right now i'm using IIS (the devil) and its just not working. any ideas, anyone?

#2 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 04 August 2006 - 02:46 PM

well, did they come direct to that page or did they come through another page/portal?  I have the same issue:  If they login first, they are coming from the server already...

Make sense?

#3 tony5429

tony5429
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 04 August 2006 - 02:52 PM

Well the default document is set as index.php so when the user types the domain name, i would assume he/she goes directly to the index.php (the script I posted above). of course, iis is m$ so there is prolly some hidden security page or something that is screwing me over. Is there any other way for PHP to get the IP address of the visitor?

#4 tony5429

tony5429
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 04 August 2006 - 03:36 PM

I guess that's the only way to do it...

#5 Salis

Salis
  • Members
  • PipPipPip
  • Advanced Member
  • 130 posts

Posted 04 August 2006 - 03:58 PM

<?php
	$ip = GetHostByName($_SERVER['REMOTE_ADDR']);
?>

^There's the script. I want to get the IP address of the visitor to the page, however, I keep getting the local IP address of the server itself (192.168.3.1). I've used gethostbyname() a million times before on apache with no problem, but right now i'm using IIS (the devil) and its just not working. any ideas, anyone?


Actually if you want just the visitors IP then try:

$ip = $_SERVER['REMOTE_ADDR'];

#6 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 04 August 2006 - 04:18 PM

<?php
	$ip = GetHostByName($_SERVER['REMOTE_ADDR']);
?>

^There's the script. I want to get the IP address of the visitor to the page, however, I keep getting the local IP address of the server itself (192.168.3.1). I've used gethostbyname() a million times before on apache with no problem, but right now i'm using IIS (the devil) and its just not working. any ideas, anyone?


If it's actually the hostname you want, use gethostbyaddr($_SERVER["REMOTE_ADDR"]);
Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users