View Full Version : How do find a persons ip address and display it in a form field?
Silver Sun
09-28-2002, 07:40 PM
How do find a persons ip address and display it in a form field?
Thanks in advance
whackaxe
09-28-2002, 08:11 PM
you need SSI to do this, its not a javascript funtion but to do what you want try this
<input type="text" value="<!--#echo var='REMOTE_ADDR'-->">
that should shopw up the users address.
i find that putting a IP checker/viewer on your site is like putting a "DONT DO ANYTHING DODGY HERE OR YOUR GOING TO THE SLAMMER!!" sign on your index page. i would disagree with it
whammy
09-29-2002, 01:57 AM
The above should work if your server allows SSI and you have named your page with an .shtml extension.
alaios
09-29-2002, 08:28 PM
?
jamescover
09-29-2002, 11:55 PM
SSI=ServerSide Includes
.shtml is the file extension used, so that the server treats the page as a SSI page, and not a regular .html page.
James
He is risen!!!
glenngv
09-30-2002, 04:15 AM
Netscape only:
<script>
if (navigator.javaEnabled()&&(document.layers||(document.getElementById&&!document.all))) {
myAddress=java.net.InetAddress.getLocalHost();
host=myAddress.getHostName();
ip=myAddress.getHostAddress();
alert(host+" = "+ip);
}
</script>
Alekz
09-30-2002, 08:28 AM
Hi,
<input type="text" value="<!--#echo var='REMOTE_ADDR'-->"> Will display the IP address of the proxy server, not of the actual user. Well if the user does not use a proxy it will work, but its rare...
You don't need to name Your page .shtml. You could use any server side scripting to do the same. More, You can make a simple html page and just include a script in the head.
<script language="JavaScript" src="ServerVars.php"> (could be ASP or almost anything else).
For the PHP
if(getenv("HTTP_CLIENT_IP")) {
$ip = getenv("HTTP_CLIENT_IP");
}
elseif(getenv("HTTP_X_FORWARDED_FOR")) {
$ip = getenv("HTTP_X_FORWARDED_FOR");
}
else {
$ip = getenv("REMOTE_ADDR");
}
print("var clientIP = '" . $ip . "';");
So in the client side JavaScript You'll have the IP of the client in the variable -> clientIP.
Alex
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.