IP detection and using the info

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • karenrichardson
    New Member
    • Feb 2008
    • 1

    IP detection and using the info

    Hi - I am not a technical person - I use dreamweaver to create basic websites. I have to have an age verification code to enter our site as it is alcohol related. Part of this is to ask the user their country, this is allocated a code and then the appropriate age verification is used and allows the user in to the site with relevant pages. I want to pick up country by IP address to reduce the number of click thru's. Has anyone done this before? Help!
    Cheers
    Karen
  • jeffstl
    Recognized Expert Contributor
    • Feb 2008
    • 432

    #2
    You can get the IP Address easy enough, depending on what kind of server you are hosted on. Hopefully IIS and you are running ASP pages cause thats what Im posting, though there are just as simple ways if you are using php, or js.

    Code:
    'ASP without Proxy detection 
    <%
    ipaddress = Request.ServerVariables("REMOTE_ADDR")
    %>
    
    
    'ASP with Proxy detection 
    <%
    ipaddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
    if ipaddress = "" then
    ipaddress = Request.ServerVariables("REMOTE_ADDR")
    end if
    %>
    Now the bad part is that once you HAVE the IP Address, the only way to determine it's country is by checking against a database of some kind. Whether you build and maintain your own database or use a hosting service is up to you.

    These are some ive seen that provide the database
    http://ip-to-country.webhost ing.info/
    http://www.ip2country. net/

    Comment

    Working...