<% response.redirect("/") %> <% On Error Resume Next ' Description: This is the registration form the for Math.com club ' ' EOD Dim strOutput, strErrors ' Determine whether this is display or processing call If Request.Form("post") = "1" Then ' Acquire the form variables strFirstName = Replace(Request.Form("name_first"), "'", "''") strLastName = Replace(Request.Form("name_last"), "'", "''") strEmail = Replace(Request.Form("email"), "'", "''") strZip = Replace(Request.Form("zip"), "'", "''") lngCountry = Request.Form("country") lngUserType = Request.Form("user_type") strUserTypeDesc = Replace(Request.Form("statusother"), "'", "''") lngAge = Request.Form("age") lngEmailList = Request.Form("info_wanted") strInterests = funGetInterests() ' Data validation If Len(strFirstName) < 1 Then strErrors = strErrors & "First name is required.
" End If If Len(strLastName) < 1 Then strErrors = strErrors & "Last name is required.
" End If If Len(strEmail) < 1 Then strErrors = strErrors & "An email address is required.
" End If If Len(strZip) < 1 Then strErrors = strErrors & "A zipcode is required.
" ElseIf Len(strZip) < 5 Then strErrors = strErrors & "The zipcode is not properly formatted.
" End If If lngEmailList = "on" Then lngEmailList = 1 Else lngEmailList = 0 End If ' If any errors, output error; otherwise, save to db If strErrors <> "" Then strErrors = "The following errors occurred with registration:

" & strErrors strOutput = funReadTemplate(Request.ServerVariables("APPL_PHYSICAL_PATH") & "thtml\registration.thtml") strOutput = funReplaceTemplate(strOutput,strErrors,strFirstName,strLastName,strEmail,strZip) Else strSQL = "INSERT INTO users (name_first, name_last, email, zip, country, user_type, user_other_desc, age, areas_of_interest, reg_date, receive_info) VALUES ('" & strFirstName & "','" & strLastName & "','" & strEmail & "','" & strZip & "'," & lngCountry & "," & lngUserType & ",'" & strUserTypeDesc & "'," & lngAge & ",'" & strInterests & "',GETDATE()," & lngEmailList & ")" Call funOpenConn() Set cmdMain = Server.CreateObject("ADODB.Command") cmdMain.ActiveConnection = cnMain cmdMain.CommandText = strSQL 'Response.Write strSQL cmdMain.Execute Call funCloseConn() ' Send the email to the list server Call funCDO_SendSimpleMail("127.0.0.1", strEmail & " (" & strFirstName & " " & strLastName & ")", "join-members@lists.math.com", "", "Subscribe", "") strOutput = funReadTemplate(Request.ServerVariables("APPL_PHYSICAL_PATH") & "thtml\registration_ok.thtml") End If Else ' Load & process the form strOutput = funReadTemplate(Request.ServerVariables("APPL_PHYSICAL_PATH") & "cgibin\registration.html") strOutput = funReplaceTemplate(strOutput,"","","","","") End If ' Output the form Response.Write strOutput Function funGetInterests() Dim arrTypes(9) Dim strResult arrTypes(1) = Request.Form("preschool") arrTypes(2) = Request.Form("K-5") arrTypes(3) = Request.Form("6-8") arrTypes(4) = Request.Form("9-12") arrTypes(5) = Request.Form("college") arrTypes(6) = Request.Form("homeschooling") arrTypes(7) = Request.Form("teaching") arrTypes(8) = Request.Form("business") arrTypes(9) = Request.Form("recreational") For idxType = 1 to UBound(arrTypes) If Len(arrTypes(idxType)) > 0 Then strResult = strResult & idxType & "," End If Next If strResult = "" Then strResult = "none" Else strResult = Left(strResult, Len(strResult) - 1) End If funGetInterests = strResult End Function Function funReplaceTemplate(strOutput, strError, strFirst, strLast, strEmail, strZip) strOutput = Replace(strOutput, "", strError) strOutput = Replace(strOutput, "{firstname}", strFirst) strOutput = Replace(strOutput, "{lastname}", strLast) strOutput = Replace(strOutput, "{email}", strEmail) strOutput = Replace(strOutput, "{zip}", strZip) funReplaceTemplate = strOutput End Function %>