Sign up for an account

<% dim problem if Request.ServerVariables("REQUEST_METHOD") = "POST" then dim UEmail, UPassword, UPassword2, UMD5Password, UAuthCode dim USalutation, UFirstName, ULastName, UOrganization, UJobTitle, UPhone, UAddress dim UAutoSubscribe, URevealUserPref, URevealOrgPref, URevealContactInfo UEmail = left(Request.Form("UEmail"), 100) UPassword = Request.Form("UPassword") UPassword2 = Request.Form("UPassword2") USalutation = left(Request.Form("USalutation"), 10) UFirstName = left(Request.Form("UFirstName"), 50) ULastName = left(Request.Form("ULastName"), 50) UOrganization = left(Request.Form("UOrganization"), 100) UJobTitle = left(Request.Form("UJobTitle"), 100) UPhone = left(Request.Form("UPhone"), 50) UAddress = Request.Form("UAddress") UAutoSubscribe = IIf(Request.Form("UAutoSubscribe") = "1", 1, 0) URevealUserPref = IIf(Request.Form("URevealUserPref") = "1", 1, 0) URevealOrgPref = IIf(Request.Form("URevealOrgPref") = "1", 1, 0) URevealContactInfo = IIf(Request.Form("URevealContactInfo") = "1", 1, 0) if len(UPassword) = 0 then problem = "Please select a password" elseif UPassword <> UPassword2 then problem = "The passwords you entered do not match" elseif len(UEmail) = 0 then problem = "Please enter your email address" elseif len(UFirstName) = 0 then problem = "Please enter your first name" elseif len(ULastName) = 0 then problem = "Please enter your last name" else UMD5Password = calcMD5(UPassword) dim conn, rs, sql set conn = Server.CreateObject("ADODB.Connection") conn.Open connectionStr sql = "SELECT * FROM [User] WHERE UEmail='" & SQLencode(UEmail) & "'" set rs = Server.CreateObject("ADODB.RecordSet") rs.Open sql, conn, adOpenKeyset, adLockOptimistic if rs.EOF then UAuthCode = generateRandomString() rs.AddNew rs("UEmail") = UEmail rs("UPassword") = UMD5Password if len(USalutation) > 0 then rs("USalutation") = USalutation rs("UFirstName") = UFirstName rs("ULastName") = ULastName if len(UOrganization) > 0 then rs("UOrganization") = UOrganization if len(UJobTitle) > 0 then rs("UJobTitle") = UJobTitle if len(UPhone) > 0 then rs("UPhone") = UPhone if len(UAddress) > 0 then rs("UAddress") = UAddress rs("UAutoSubscribe") = UAutoSubscribe rs("URevealUserPref") = URevealUserPref rs("URevealOrgPref") = URevealOrgPref rs("URevealContactInfo") = URevealContactInfo rs("UAuthCode") = UAuthCode rs.Update On Error Resume Next dim email, link link = "http://maic.jmu.edu/LLDB/activate.asp?a=" & UAuthCode & Server.URLEncode(UEmail) link = "http://maic.jmu.edu/LLDB/activate.asp?a=" & UAuthCode & Server.URLEncode(UEmail) sch = "http://schemas.microsoft.com/cdo/configuration/" Set cdoConfig = CreateObject("CDO.Configuration") With cdoConfig.Fields .Item(sch & "sendusing") = 2 ' cdoSendUsingPort .Item(sch & "smtpserver") = "134.126.99.168" .update End With Set email = CreateObject("CDO.Message") If Request.form("laji") <> "maic" Then Response.Redirect "../index.htm" End If with email Set .Configuration = cdoConfig .From = emailSender .To = UEmail .Subject = "MAIC Lessons Learned - Account Activation Code" '.BodyFormat = 0 '.MailFormat = 0 .HtmlBody = "" & vbNewLine & _ "Thank you for requesting an account with the MAIC Lessons Learned Database. " & _ "Please click the following link to activate your account:" & vbNewLine & _ "" & link & "" & _ "" .Send End with Set email = Nothing Set cdoConfig = Nothing If Err.Number <> 0 then problem = "Could not generate email. Please go back and check your email address" End If On Error Goto 0 else problem = "An account for the email address you specified already exists. If you forgot you password, you can request a new one" end if rs.Close rs = null conn.Close conn = null end if if len(problem) > 0 then %>
Your request could not be processed: <%= problem %>. Please go back and try again.
<% else %>
Success! Your sign-up request has been submitted.
Important: Within a short period of time, you will receive an email with a link that you will have to click (or copy and paste into your browser) in order to activate your account. You cannot post lessons or participate in a discussion until you have activated your account. Contact <%=emailSender%> if you have problems activating your account.
<% end if else %>
" onSubmit="return formValidator(this);">
Your Email Address
Password
Retype Password
Salutation
First Name
Last Name
Organization (optional)
Job Title (optional)
Phone (optional)
Address
(optional)
Message <% If Request.form("URL") <> "" Then Response.Redirect "../index.htm" End If %>
Subscribe to all
categories
  If checked, you will receive a notice by email every time a new lesson
is added to the Lessons Database
Pre-check "Reveal
Organization"
  If checked, the "Reveal Organization" box will be checked by default
when you post lessons or participate in discussions (you will be
able to uncheck this box if desired)
Show contact
information
  If checked, your contact information will appear with all of your posted
comments. Note: Your name will always appear with your comments.
Please enter maic in the box. This is used to prevent spams.
 
  
<% end if %>