|
|
ItsMe 06-20-2005, 05:45 PM Hi,
I have tried a few pieces of code to find and echo the IP adress in a page but have not had any success. Im sure its fairly simple but i cant do it!
Can someone please tell me how to do this sucessfully.
Fashong 06-20-2005, 06:31 PM <?php
echo $_SERVER['REMOTE_ADDR'];
?>
or you can do this
<?php
$IP = $_SERVER['REMOTE_ADDR'];
echo $IP;
?>
ItsMe 06-20-2005, 06:35 PM That doesnt work, it just comes up blank.
Any ideas?
Fashong 06-20-2005, 06:35 PM Does your webserver even support php?? lol
ItsMe 06-20-2005, 06:47 PM yes it does, im running several PHP scripts on it.
ItsMe 06-20-2005, 06:50 PM The following is the code i am using.
Your IP is: <?php echo $_SERVER['REMOTE_ADDR']; ?>It outputs "Your IP is: "
Fashong 06-20-2005, 07:03 PM Can you send me your url?
ItsMe 06-20-2005, 07:18 PM Sure - http://andrewthomas.org.uk/ip/ip.php
Fashong 06-20-2005, 07:21 PM <?php
echo "<font color=\"black\">$_SERVER['REMOTE_ADDR']</font>";
?>
Maybe it blends in, lol. I am sorry, I have not a clue. This happened to me ages ago and I don't know how I fixed it.
ItsMe 06-20-2005, 08:05 PM Ok, thanks for your help. If you find a solution please let me know otherwise no problems.
Thanks again!
JamieR 06-20-2005, 08:16 PM unless that kind of thing has been somehow disabled by your host, I'm using <?php echo $_SERVER['REMOTE_ADDR']; ?> and it work's fine :p
ItsMe 06-20-2005, 09:05 PM Is there any other way of doing this or not?
marek_mar 06-20-2005, 10:16 PM $_SERVER array values are set by the server. If they're not set you should ask the admin why the server doesn't set them. Create a page with
<?php phpinfo(); ?>
in it and search for REMOTE_ADDR and to what it's set.
JamieR 06-20-2005, 10:18 PM It would be extremley weird IWHT that $_SERVER variables be disabled...
Nightfire 06-21-2005, 12:15 AM Try
echo getenv('REMOTE_ADDR');
ItsMe 06-21-2005, 11:30 AM Cheers Nightfire :thumbsup: , it works!
Thanks a lot :)
ItsMe 06-21-2005, 06:51 PM Is there anyway to get the host name aswell, either from the PHP code or from the ip address?
Thanks
JamieR 06-21-2005, 06:58 PM Yeah:
<?php
$hostname = gethostbyaddr(getenv('REMOTE_ADDR');
echo $hostname;
?>
should output the ISP host from the IP address ;)
http://uk2.php.net/gethostbyaddr
Jamie.
ItsMe 06-21-2005, 07:03 PM Thanks Weazel :thumbsup:
JamieR 06-21-2005, 07:13 PM Thanks Weazel :thumbsup:
No problem ;)
|
|
|
|
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum
vBulletin® v3.8.2, Copyright ©2000-2013, Jelsoft Enterprises Ltd.