Hi new to all this web programming stuff but i wonder if someone could give me some code for getting the ip address of all who view my web page?
thanks
B
Printable View
Hi new to all this web programming stuff but i wonder if someone could give me some code for getting the ip address of all who view my web page?
thanks
B
what language?
Javascript, vbscript or html hell i dont really care!
;) :p
how about ASP?
It's really easy that way...(i suppose something simular would work for vbs)
Code:<% = Request.ServerVariables("REMOTE_HOST") %>
Yeah, all server-side CGI languages can get the ip address pretty easy with the REMOTE_HOST or REMOTE_ADDR cgi variables. REMOTE_ADDR will be the ip address, on some servers, REMOTE_HOST will name resolve the ip address.
Perl = $ENV{'REMOTE_ADDR'}
PHP = $remote_ip=getenv("REMOTE_ADDR");
just in case you don't want ASP or VBS
i wonder if there is any way to do it in javascript?
There's this, I didn't test it.
Code:browserName = navigator.appName
browserVer = parseInt(navigator.appVersion)
ipAdd = ""
if (browserName == "Netscape" && navigator.javaEnabled()) {
if (browserVer >= 4) {
ipAdd = java.net.InetAddress.getLocalHost().getHostName()
}
else {
ipAdd = java.net.InetAddress.getLocalHostName()
}
}
if (ipAdd != "") {
document.writeln("<H1>Your IP address is: " + ipAdd + ".</H1>")
if (ipAdd.substring(0,7) == "17.254.") {
document.write("<H2>Welcome, visitor from Apple!</H2>")
}
}
thanks, i'll check it out
Let me know if that code works. Getting an ip address through client-side javascript is a security hole that would need to be closed.