Forums

ASP

This topic is locked

Assistance in helping tweek a redirect anti-spam script please.

Posted 15 May 2010 21:30:07
1
has voted
15 May 2010 21:30:07 Somjad P posted:
Greetings!

Thank you for your input. This forum is always full of good information and great people.

I have a page that I currently have running a script from Dreamweaver MX that has an include file. This include file redirects a user to page 1 if their IP is xxx or page 2 if it is yyy. I have a database that has a list of IP addresses that I query out and I want to compare it to the current user's IP. If it matches any of the nonapproved IPs that are in the database then I want them to go a page 1 but if there are no matches then go to page two.

Below is what I have so far. The problem I have is that it seems to let everything go to page 2 and does not stop and go to page 1 even if one of the ip is showing a match. Am I placing the "else" command in the wrong place? (I tried to substitue the redirect with just a response.write to test it and the list does show up with the correct response but it is not executing the ELSE command...it just displays the list)

Thank you so much and have a great day!


<%
startrw = 0
endrw = HLooper1__index
numberColumns = 10
numrows = -1
while((numrows <> 0) AND (Not bannediplist.EOF))
startrw = endrw + 1
endrw = endrw + numberColumns
%>
<tr align="center" valign="top">
<%
While ((startrw <= endrw) AND (Not bannediplist.EOF))
%>
<td><%
dim ipban
dim clientinformation

ipban = Request.ServerVariables("REMOTE_ADDR"
clientinformation = (clientinfo.Fields.Item("ClientID".Value)
If (bannediplist.Fields.Item("IPnum".Value) = ipban then
response.Redirect (("IPSTblocked.asp?ClientID="& clientinformation)
else
response.redirect ((clientinfo.Fields.Item("clientwebsite".Value))


%> </td>
<%
startrw = startrw + 1
bannediplist.MoveNext()
end if
Wend

%>
</tr>
<%
numrows=numrows-1
Wend
%>
Edited by - Somjad P on 15 May 2010  21:30:33

Edited by - Somjad P on 20 May 2010  17:56:18

Replies

Replied 03 Jun 2010 13:13:08
03 Jun 2010 13:13:08 Seb Adlington replied:
Hi Somjad,

try putting the code above your opening head statement, that way the page won't load at all and the divert happens as soon as they hit the page

Cheers

Seb

Reply to this topic