PDA

View Full Version : Script to check and show IP address



zxt
Aug 17th, 2009, 03:39 PM
I want to know what script do I need to put in on a web page or blog to show IP address of the visitor like this one -> whatsmyip.net

Not sure where to post this so accept my apology if this is not the right forum.

Thanks in advance.

BWiz
Aug 17th, 2009, 03:43 PM
This would fall under the server-side forum. You need to know what language you have access to. In PHP it would be relativley simple, and I think you could also do it JavaScript, however, a user can disable JavaScript on their browser.

zxt
Aug 17th, 2009, 04:46 PM
Thanks Bwiz.

Mod pls just move my post to Server side.

BTW, what script usually people use in blogs?

_Aerospace_Eng_
Aug 17th, 2009, 08:35 PM
PHP would probably be the language used by most people because its free and is widely available on web hosts. To show the user's ip address in php you can use this

<?php echo $_SERVER['REMOTE_ADDR']; ?>

zxt
Aug 21st, 2009, 02:54 PM
Thanks.

How to do it in Java? I've checked Blogger.com and it seems like it only accepts Java scripts.

_Aerospace_Eng_
Aug 21st, 2009, 03:07 PM
Java or Javascript? They are entirely different languages.

ckeyrouz
Aug 21st, 2009, 05:23 PM
if it is in Java:

request.getRemoteAddr()