View Single Post
Old 07-31-2012, 08:39 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,249
Thanks: 59
Thanked 3,999 Times in 3,968 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Code:
<% 
Dim captcha
capcha = 0
On Error Resume Next
    captcha = CINT(Request.Form("year"))
On Error GoTo 0

If captcha <> Year(Date) Then
    Response.Redirect("wrong.asp")
End If
%>
Year(Date) will be a *NUMBER* so you want to ensure that what comes from the user is also a number.

The ON ERROR code allows you to force the value from the <form> posting to be a number. If it is not, then captcha will remain at 0 and of course not match the year of today's date.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote