Solved

Over 18 disclaimer

Posted on 2006-11-17
6
330 Views
Last Modified: 2010-08-05
Hi there,
I have page that takes information form the user but i need to trigger a flag or better yet to redirect she/he to a pdf depending on his/her age. Is there a way to do this an ASP?
if the filed Date of Birth is filed with a date that is not over 18 then take it to the PDF, I'm not so sure if the need of AJAX is need it here, but i'm new to ASP and not to mention AJAX (LOL) so any suggestion will be apreciate it
Thanks
JSCTECHY
0
Comment
Question by:jsctechy
  • 4
  • 2
6 Comments
 
LVL 9

Accepted Solution

by:
deathtospam earned 500 total points
ID: 17966183
jsctechy --

This script should help demonstrate how to get the job done.

================================================
<%
      Option Explicit

      Dim bIsPostback, sMonth, sDay, sYear, iMonth, iDay, iYear
      Dim dtUserDateOfBirth, iUserAge, sDisplayMessageHTML

      '// Use this constant to control the minimum age requirement.
      Const MINIMUM_AGE_IN_YEARS = 18

      bIsPostback = (Trim(Request("IsPostback")) <> "")

      If NOT bIsPostback Then
            '// First visit to the page -- set all field values to be empty.
            sMonth = "":  sDay = "":  sYear = ""
      Else
            '// User has already submitted the form at least once -- retrieve the form values.
            sMonth = Trim(Request("DOBMonth"))
            sDay = Trim(Request("DOBDay"))
            sYear = Trim(Request("DOBYear"))

            If IsNumeric(sMonth) AND IsNumeric(sDay) AND IsNumeric(sYear) Then
                  '// The form values are all valid numbers.
                  iMonth = CLng(Request("DOBMonth"))
                  iDay = CLng(Request("DOBDay"))
                  iYear = CLng(Request("DOBYear"))

                  '// Use the form values to build the user's birth date.
                  dtUserDateOfBirth = DateSerial(iYear, iMonth, iDay)

                  '// Find out how many years old the user is.
                  iUserAge = DateDiff("yyyy", dtUserDateOfBirth, Now())
                  Call Response.Write("User is " & iUserAge & " years old [born on <u>" & DateValue(dtUserDateOfBirth) & "</u>]<br>" & vbNewLine)

                  '// Perform the age validation.
                  If (iUserAge >= MINIMUM_AGE_IN_YEARS) Then
                        Call Response.Write("User is at least " & MINIMUM_AGE_IN_YEARS & " years of age.<br>" & vbNewLine)
                  Else
                        Call Response.Write("User is not " & MINIMUM_AGE_IN_YEARS & " years old -- access denied.<br>" & vbNewLine)
                  End If
                  
                  '// Stop processing the page.
                  Call Response.End()
            End If
      End If
%>
<html>
      <head><title>How To Validate Age Using Classic ASP</title></head>
      <body>
            <form action="<%=Request.ServerVariables("SCRIPT_NAME")%>" method="post">
            <input type="hidden" name="IsPostback" value="True">

            <table>
                  <tr>
                        <td>Month</td>
                        <td><input type="text" name="DOBMonth" size="10" value="<%=Server.HTMLEncode(sMonth)%>"></td>
                  </tr>
                  <tr>
                        <td>Day</td>
                        <td><input type="text" name="DOBDay" size="10" value="<%=Server.HTMLEncode(sDay)%>"></td>
                  </tr>
                  <tr>
                        <td>Year</td>
                        <td><input type="text" name="DOBYear" size="10" value="<%=Server.HTMLEncode(sYear)%>"></td>
                  </tr>
                  <tr><td colspan="2">&nbsp;</td></tr>
                  <tr>
                        <td colspan="2"><input type="submit" value="Submit"></td>
                  </tr>
            </table>
      </body>
</html>
================================================

-= DeathToSpam =-
0
 
LVL 1

Author Comment

by:jsctechy
ID: 17966301
that seems to work properly, but if i want to direct the user if is < 18 years old to a pdf called Apply.pdf and if it is over continue to another page called Application.asp how would i add those to thing on this code?
Thanks
0
 
LVL 9

Expert Comment

by:deathtospam
ID: 17966455
Then modify the part of my code that does the age validation:

<%
              '// Perform the age validation.
               If (iUserAge >= MINIMUM_AGE_IN_YEARS) Then
                    'Call Response.Write("User is at least " & MINIMUM_AGE_IN_YEARS & " years of age.<br>" & vbNewLine)
                    Call Response.Redirect("http://www.somewhere.com/Application.asp")
               Else
                    'Call Response.Write("User is not " & MINIMUM_AGE_IN_YEARS & " years old -- access denied.<br>" & vbNewLine)
                    Call Response.Redirect("http://www.somewhere.com/Apply.pdf")
               End If
%>


-= DeathToSpam =-
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 1

Author Comment

by:jsctechy
ID: 17967843
do they have to be links like that?
or can i just have this?
>> Call Response.Redirect("application.asp")
0
 
LVL 1

Author Comment

by:jsctechy
ID: 17967899
Also when i add all this code to my page i got an error saying
Microsoft VBScript compilation error '800a0400'

Expected statement

/sp/volunteer/index.asp, line 185

Option Explicit
^
0
 
LVL 1

Author Comment

by:jsctechy
ID: 17967912
disregard that error i have put it after the html tags and thats the reaon why i was getting it ;-)
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Issue with Loop 4 58
Passing Parameter to Stored Procedure 4 24
Connecting to multiple databases to create a Dashboard 5 26
Syntax for query to update table 2 14
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question