Jump to content

Archived

This topic is now archived and is closed to further replies.

tony5429

plz help with gethostbyname()

Recommended Posts

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

^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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
[quote author=tony5429 link=topic=102980.msg409547#msg409547 date=1154702374]
[code]
<?php
$ip = GetHostByName($_SERVER['REMOTE_ADDR']);
?>
[/code]

^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?
[/quote]

Actually if you want just the visitors IP then try:

$ip = $_SERVER['REMOTE_ADDR'];

Share this post


Link to post
Share on other sites
[quote author=tony5429 link=topic=102980.msg409547#msg409547 date=1154702374]
[code]
<?php
$ip = GetHostByName($_SERVER['REMOTE_ADDR']);
?>
[/code]

^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?
[/quote]

If it's actually the hostname you want, use gethostbyaddr($_SERVER["REMOTE_ADDR"]);

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.