Forum Moderators: open
Basically i have the following script that detects a users IP, country and Country code from a .dat database.
<%
Option Explicit
%>
<!--#include file="GeoIP.asp"-->
<%
Dim oGeoIP,strErrMsg
Dim strIP,strCountryName,strCountryCode
Set oGeoIP = New CountryLookup
oGeoIP.GeoIPDataBase = Server.MapPath("GeoIP.dat")
If oGeoIP.ErrNum(strErrMsg) <> 0 Then
Response.Write(strErrMsg)
Else
strIP = request.ServerVariables("REMOTE_ADDR")
strCountryName = oGeoIP.lookupCountryName(strIP)
strCountryCode = oGeoIP.lookupCountryCode(strIP)
End If
Set oGeoIP = Nothing
%>
<html>
<body>
IP: <%=strIP%> <br>
Country: <%=strCountryName%> <br>
Country Code: <%=strCountryCode%>
</body>
</html>
I want to to change the script so that depending on the country the user is from, instead of displaying their country name, i want the script to redirect the user to a page that is configured in the asp file.
So, basically if the user is from the following countries it should take them to the following pages:
United States = "usa/index.html"
United Kingdom = "uk/index.html"
France = "fr/index.html"
Default = "europe/index.html"
if the user is not from any of the 3 countries configured in the asp file, then the user should be taken to the Default page which is also configured in the asp file
I AM IN URGENT NEED TO GET THIS WORKING AND WOULD BE VERY GREATFUL IF SOMEONE CAN HELP ME OUT
I appreciate anyones help
Many Thanks
Linda
<%
Option Explicit
%>
<!--#include file="GeoIP.asp"-->
<%
Dim oGeoIP,strErrMsg
Dim strIP,strCountryName,strCountryCode
Set oGeoIP = New CountryLookup
oGeoIP.GeoIPDataBase = Server.MapPath("GeoIP.dat")
If oGeoIP.ErrNum(strErrMsg) <> 0 Then
Response.Write(strErrMsg)
Else
strIP = request.ServerVariables("REMOTE_ADDR")
strCountryName = oGeoIP.lookupCountryName(strIP)
strCountryCode = oGeoIP.lookupCountryCode(strIP)
IF strCountryName = "United States" Then
Response.redirect("usa/index.html")
IF strCountryName = "United Kingdom" Then
Response.redirect("uk/index.html")
IF strCountryName = "France" Then
Response.redirect("fr/index.html")
Else
Response.redirect("europe/index.html")
End If
Set oGeoIP = Nothing
%>
<html>
<body>
IP: <%=strIP%> <br>
Country: <%=strCountryName%> <br>
Country Code: <%=strCountryCode%>
</body>
</html>
what can be wrong?
this is how i put it:
<%
IF strCountryName = "United States" Then
Response.redirect("usa/index.html")
IF strCountryName = "United Kingdom" Then
Response.redirect("uk/index.html")
IF strCountryName = "France" Then
Response.redirect("fr/index.html")
Else
Response.redirect("europe/index.html")
END IF
%>
<html>
<body>
</body>
</html>
<%
Option Explicit
%>
<!--#include file="GeoIP.asp"-->
<%
Dim oGeoIP,strErrMsg
Dim strIP,strCountryName,strCountryCode
Set oGeoIP = New CountryLookup
oGeoIP.GeoIPDataBase = Server.MapPath("GeoIP.dat")
If oGeoIP.ErrNum(strErrMsg) <> 0 Then
Response.Write(strErrMsg)
Else
strIP = request.ServerVariables("REMOTE_ADDR")
strCountryName = oGeoIP.lookupCountryName(strIP)
strCountryCode = oGeoIP.lookupCountryCode(strIP)
IF strCountryName = "United States" Then
Response.redirect("usa/index.html")
IF strCountryName = "United Kingdom" Then
Response.redirect("uk/index.html")
IF strCountryName = "France" Then
Response.redirect("fr/index.html")
Else
Response.redirect("europe/index.html")
END IF
End If
Set oGeoIP = Nothing
%>
Is a Select similar to a switch() [php.net] statement?
HTTP 500 - Internal server error
Internet ExplorerThis problem occurs because there is an error processing the ASP script and "Friendly HTTP error messages" are enabled in Internet Explorer which do not allow you to see the details of the problem.
Solution(s):
In IE, turn off Friendly HTTP error messages by choosing tools - internet options - advanced. Then you should get the real error message and line number of the error.
<%
Option Explicit
%>
<!--#include file="GeoIP.asp"-->
<%
Dim oGeoIP,strErrMsg
Dim strIP,strCountryName,strCountryCode
Set oGeoIP = New CountryLookup
oGeoIP.GeoIPDataBase = Server.MapPath("GeoIP.dat")
If oGeoIP.ErrNum(strErrMsg) <> 0 Then
Response.Write(strErrMsg)
Else
strIP = request.ServerVariables("REMOTE_ADDR")
strCountryName = oGeoIP.lookupCountryName(strIP)
strCountryCode = oGeoIP.lookupCountryCode(strIP)
If strCountryName = "United States" Then
Response.redirect("usa/index.html")
ElseIf strCountryName = "United Kingdom" Then
Response.redirect("uk/index.html")
ElseIf strCountryName = "France" Then
Response.redirect("fr/index.html")
Else
Response.redirect("europe/index.html")
End If
End If
Set oGeoIP = Nothing
%>