Hi Mark,
Thanks for your help.
I'm not sure which of the options you have suggested I am using.
Heres my ASP code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/DataLinks.asp" -->
<%
Dim Get_Destination__MMColParam
Get_Destination__MMColParam = "1"
If (Request.QueryString("Link_ID") <> "") Then
Get_Destination__MMColParam = Request.QueryString("Link_ID")
End If
%>
<%
Dim Get_Destination
Dim Get_Destination_numRows
Set Get_Destination = Server.CreateObject("ADODB.Recordset")
Get_Destination.ActiveConnection = MM_DataLinks_STRING
Get_Destination.Source = "SELECT * FROM TBL_LINKS WHERE Link_No = " +
Replace(Get_Destination__MMColParam, "'", "''") + ""
Get_Destination.CursorType = 0
Get_Destination.CursorLocation = 2
Get_Destination.LockType = 1
Get_Destination.Open()
Get_Destination_numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<% Response.Redirect ((Get_Destination.Fields.Item("Link_path").Value)) %>
</body>
</html>
<%
Get_Destination.Close()
Set Get_Destination = Nothing
%>
Can you show me how to do it ?
I really appreciate your help.
Jon
Mark Rae said:
I have a page that is used to redirect the user to a page depending on
the perameter they passed.
So if they send
http://mydomain.com?link_id=1 then it should go to
www.google.com
but
http://mydomain.com?link_id=2 would go to
www.yahoo.co.uk
the problem is if the user puts
http://mydomain.com?link_id=9999999 and I dont have a link for 99999999
in my database so how do I redirect them to a different page such as
http://mydomain.com/stop_messing_with_the_url_you_nosy_git.html
Thanks for your advice
Presumably, you're looking up the id name/value pair from the QueryString
in a database?
If so, then just check for there being no records returned. How you do
this will depend on how you are fetching the data:
If you're using a DataReader, inspect its HasRows property.
If you're using DataSet, inspect its Tables[0].Rows.Count value
If you're using an ExecuteScalar, then check for the value being null (or
however you're doing it...)
Alternatively, and a much better solution, would be to prevent this
happening in the first place by not using a QueryString at all so that the
user couldn't modify it... When preserving state, QueryString should be
seen as the absolute last resort...