% @ Language="VBSCRIPT" %> <% Option Explicit %> <% On Error Resume Next rem - get the action that is to be performed Dim lcAction lcAction = Trim(Request.QueryString("action")) rem - dimension our variables first Dim lvId, lcDesc, lvDate, lcEventLst, lcEventId, lcAcceptTerms, llAcceptTerms Dim lcTitle, lcLastName, lcFirstName, lcAddress1, lcAddress2, lcCity, lcState, lcZip, lcPhone1, lcPhone2, lcEmail, lcPmtMethod, lcEmergCont, lcEmergPhone1, lcEmergPhone2, lnBirthMonth, lnBirthDay, lcBMonth, lcBDay Dim llError, llShowPage, llIncomplete, llPhone1Error, llPhone2Error, llEPhone1Error, llEPhone2Error, lcDateRegistered, oConn, cConnect, ors, lcSQLString, lnDups, lcDupCheck, i, lcOptions, lcHowHeard, llShowPmtDD, lcPmtInfo, lcPmtOption, lcPmtPlan lcDupCheck = "false" llError = False llShowPage = False llIncomplete = False llPhone1Error = False llPhone2Error = False llEPhone1Error = False llEPhone2Error = False llAcceptTerms = False llShowPmtDD = False rem default the event id to blank lcEventId = "0" rem set a session flag so we know that the user is in the registration form when they attempt to rem access the list of members Session("registering") = "true" If lcAction = "validate" Or lcAction = "getevent" Then rem - user either selected an event or clicked the register button so check if everything is there... lcTitle = Trim(Request.Form("title")) lcEventId = Trim(Request.Form("lsteventid")) lcLastName = Trim(Request.Form("last_name")) lcFirstName = Trim(Request.Form("first_name")) lcAddress1 = Trim(Request.Form("address1") ) lcAddress2 = Trim(Request.Form("address2")) lcCity = Trim(Request.Form("city")) lcState = Trim(Request.Form("state")) lcZip = Trim(Request.Form("zip")) lcPhone1 = Trim(Request.Form("phone1")) lcPhone2 = Trim(Request.Form("phone2")) lcEmail = Trim(Request.Form("email")) lcPmtMethod = Request.Form("pmt_method") lcEmergCont = Trim(Request.Form("emerg_contact")) lcEmergPhone1 = Request.Form("emerg_phone1") lcEmergPhone2 = Request.Form("emerg_phone2") lnBirthMonth = Request.Form("birth_month") lnBirthDay = Request.Form("birth_day") lcAcceptTerms = Trim(Request.Form("opt_rt")) lcHowHeard = Trim(Request.Form("how_heard")) lcPmtOption = Trim(Request.Form("pmtoption")) rem - if we're validating the data, check for duplicates If lcAction = "validate" AND (lcLastName <> "" And lcFirstName <> "") Then lcSQLString = "SELECT COUNT(*) AS 'dups' FROM sr_signups WHERE event_no = " & lcEventId & " AND last_name = '" & CleanValue(lcLastName, False) & "' AND first_name = '" & CleanValue(lcFirstName, False) & "'" Set oConn = Server.CreateObject("ADODB.connection") If TypeName(oConn) = "Nothing" then llError = True End If If llError = False Then cConnect = Application("connection_string") oConn.Open cConnect If oConn.State <> &H00000001 Then llError = True End If End If If llError = False Then Set ors = oConn.Execute(lcSQLString ) If TypeName(ors) = "Nothing" Then llError = True Else rem - check if the count is not zero lnDups = ors.Fields("dups").value If lnDups <> 0 Then rem - we got a dup! pass a "true" value to the error page llShowPage = False lcDupCheck = "true" End If End If ors.Close() Set ors = Nothing End If oConn.Close Set oConn = Nothing End If rem - if we're validating, make sure required fields are entered if lcAction = "validate" AND lcDupCheck = "false" then rem - first check the name and address If lcLastName = "" Or lcFirstName = "" Or _ lcAddress1 = "" Or lcCity = "" Or lcState = "" Or _ lcZip = "" Or Not MyIsNumber(lcZip) Or Len(lcZip) <> 5 Or _ lcHowHeard = "" Or _ lcPhone1 = "" Or lcEmail = "" Then llIncomplete = True llShowPage = True End If If lcEventId = "" Or lcEventId = "0" Then llIncomplete = True llShowPage = True End If rem check the emergency contact If lcEmergCont = "" Or lcEmergPhone1 = "" Then llIncomplete = True llShowPage = True End If rem - make sure the phone numbers are valid If llIncomplete = False Then If Len(lcPhone1) <> 10 Then If Len(lcPhone1) <> 12 Or Mid(lcPhone1, 4, 1) <> "-" Or Mid(lcPhone1, 8, 1) <> "-" Then llIncomplete = True llShowPage = True llPhone1Error = True End If End If If Len(lcEmergPhone1) <> 10 Then If Len(lcEmergPhone1) <> 12 Or Mid(lcEmergPhone1, 4, 1) <> "-" Or Mid(lcEmergPhone1, 8, 1) <> "-" Then llIncomplete = True llShowPage = True llEPhone1Error = True End If End If End If rem - make sure the second phone number is valid If Len(lcPhone2) <> 10 Then If Len(lcPhone2) <> 12 Or Mid(lcPhone2, 4, 1) <> "-" Or Mid(lcPhone2, 8, 1) <> "-" Then llIncomplete = True llShowPage = True llPhone2Error = True End If End If rem - make sure the second emergency phone number is valid If Len(lcEmergPhone2) <> 10 Then If Len(lcEmergPhone2) <> 12 Or Mid(lcEmergPhone2, 4, 1) <> "-" Or Mid(lcEmergPhone2, 8, 1) <> "-" Then llIncomplete = True llShowPage = True llEPhone2Error = True End If End If rem check the payment method If lcPmtMethod = "" Then llIncomplete = True llShowPage = True End If rem check the payment option If lcPmtOption = "Not Selected" Then llIncomplete = True llShowPage = True End If rem make sure the user accepts the terms If lcAcceptTerms <> "A" Then llIncomplete = True llShowPage = True llAcceptTerms = True End If rem - if we have all the data, go ahead and save If llIncomplete = False Then Set oConn = Server.CreateObject("ADODB.connection") If TypeName(oConn) = "Nothing" then llError = True End If If llError = False Then cConnect = Application("connection_string") oConn.Open cConnect If oConn.State <> &H00000001 Then llError = True End If End If rem - save the registered datetime, last name, first name values so we can pass it to our confirmation page lcDateRegistered = FormatDateTime(DateAdd("h",-3,Now)) rem - cstr will convert a zero to a blank so we need to make sure we save it as a zero to avoid sql errors If lnBirthMonth = 0 Then lcBMonth = "0" Else lcBMonth = CStr(lnBirthMonth) End If If lnBirthDay = 0 Then lcBDay = "0" Else lcBDay = CStr(lnBirthDay) End if rem - write our INSERT string lcSQLString = "INSERT INTO sr_signups (event_no, title, last_name, first_name, address1, address2, city, state, zip, phone1, phone2, email, pmt_method, emerg_contact," & _ "emerg_phone1, emerg_phone2, birth_month, birth_day, signup_date, verified, how_heard, pmt_option) VALUES (" &_ "" & lcEventId & "," &_ "'" & Trim(CleanValue(lcTitle, False)) & "'," &_ "'" & Trim(CleanValue(lcLastName, False)) & "'," &_ "'" & Trim(CleanValue(lcFirstName, False)) & "'," &_ "'" & Trim(CleanValue(lcAddress1, False)) & "'," &_ "'" & Trim(CleanValue(lcAddress2, False)) & "'," &_ "'" & Trim(CleanValue(lcCity, False)) & "'," &_ "'" & Trim(CleanValue(lcState, False)) & "'," &_ "'" & Trim(CleanValue(lcZip, False)) & "'," &_ "'" & Trim(CleanValue(lcPhone1, True)) & "'," &_ "'" & Trim(CleanValue(lcPhone2, True)) & "'," &_ "'" & Trim(CleanValue(lcEmail, False)) & "'," &_ "'" & Trim(lcPmtMethod) & "'," &_ "'" & Trim(CleanValue(lcEmergCont, False)) & "'," &_ "'" & Trim(CleanValue(lcEmergPhone1, True)) & "'," &_ "'" & Trim(CleanValue(lcEmergPhone2, True)) & "'," &_ "" & lcBMonth & "," &_ "" & lcBDay & "," &_ "'" & lcDateRegistered & "', 'N'," &_ "'" & Trim(CleanValue(lcHowHeard, False)) & "'," &_ "'" & Trim(CleanValue(lcPmtOption, False)) & "' )" If llError = False Then oConn.Execute( lcSQLString) oConn.Close End If rem if no errors, go back to the menu If llError = False then lcLastName = lcLastName & ", " & lcFirstName Response.Redirect "confirm.asp?reg=" & lcDateRegistered & "&RegName=" & lcLastName & "&error=false" End If End If end if rem if this post is caused by user selecting an event, get payment options If (lcAction = "getevent" or lcAction = "validate") and lcDupCheck = "false" Then llShowPage = True lcSQLString = "SELECT event_fee, pmt_option1, pmt_option2, pmt_option3, pmt_option4, pmt_option5, pmt_plan FROM sr_event WHERE record_id = " & lcEventId Set oConn = Server.CreateObject("ADODB.connection") If TypeName(oConn) = "Nothing" then llError = True End If If llError = False Then cConnect = Application("connection_string") oConn.Open cConnect If oConn.State <> &H00000001 Then llError = True End If End If If llError = False Then Set ors = oConn.Execute(lcSQLString ) If TypeName(ors) = "Nothing" Then llError = True Else rem get the payment information lcPmtPlan = Trim(ors.Fields("pmt_plan").value) If Trim(ors.Fields("pmt_option2").value) = "" Then rem there's only one option so hard code it lcPmtInfo = Trim(ors.Fields("pmt_option1").value) Else rem there are multiple options so build a dropdown list lcPmtInfo = "" llShowPmtDD = True End If End If ors.Close() Set ors = Nothing End If oConn.Close Set oConn = Nothing End if Else rem - we're loading the page for the first time, we need to initialize variables for the form llShowPage = True rem - initialize variables lcTitle = "" lcLastName = "" lcFirstName = "" lcAddress1 = "" lcAddress2 = "" lcCity = "" lcState = "" lcZip = "" lcPhone1 = "" lcPhone2 = "" lcEmail = "" lcPmtMethod = "" lcEmergCont = "" lcEmergPhone1 = "" lcEmergPhone2 = "" lnBirthMonth = 0 lnBirthDay = 0 lcPmtOption = "" End if if llShowPage = True Then rem we need to build the list of events rem - FIRST, get a list of events, display in a dropdown lcSQLString = "SELECT record_id, descriptn, event_date FROM sr_event WHERE event_completed <> 'Y' AND remove_rec <> 'Y' ORDER BY event_date DESC" Set oConn = Server.CreateObject("ADODB.connection") If TypeName(oConn) = "Nothing" then llError = True End If If llError = False Then cConnect = Application("connection_string") oConn.Open cConnect If oConn.State <> &H00000001 Then llError = True End If End If If llError = False Then Set ors = oConn.Execute(lcSQLString ) If TypeName(ors) = "Nothing" Then llError = True Else rem add an option to the drop down to ask the user to select an option If lcEventId = "0" Then lcEventLst = "" Else lcEventLst = "" End If rem - read in the values, first get the unverified signups ors.MoveFirst() Do Until ors.Eof lvId = CStr(ors.Fields("record_id").value) lcDesc = Trim(ors.Fields("descriptn").value) lvDate = CStr(FormatDateTime(ors.Fields("event_date").value,2)) If lvId = lcEventId Then lcEventLst = lcEventLst & "" Else lcEventLst = lcEventLst & "" End If ors.MoveNext() Loop ors.Close() Set ors = Nothing End If End If oConn.Close Set oConn = Nothing rem - if we got an error, show an error page instead of the registration form If llError Then llShowPage = False End If End if If llShowPage = False Then Response.Redirect "confirm.asp?error=true&dupcheck=" & lcDupCheck Else %>