%@ Language=VBScript %> <% Option Explicit %>
<% Dim objRS Dim sSQL Dim objRSTeacher 'For Teacher Record info Dim Mailer 'Check for a valid email address before creating the account If Not IsValidEmail(Request.Form("email")) Then Response.Redirect "error.asp?error=bademail" ElseIf Trim(Request.Form("Password")) = "" Then Response.Redirect "error.asp?error=badpassword" ElseIf Trim(Request.Form("Last")) = "" Or Trim(Request.Form("First")) = "" Then Response.Redirect "error.asp?error=badname" ElseIf Not IsAlpha(Trim(Request.Form("Last"))) Or Not IsAlpha(Trim(Request.Form("First"))) Then Response.Redirect "error.asp?error=badname" End If sSQL = "SELECT * From Students Where email = '" & Request.Form("email") & "'" Set objRS = Server.CreateObject("ADODB.Recordset") objRS.Open sSQL, objConn, adOpenDynamic, adLockOptimistic, adCmdText 'Make sure we don't add a duplication account (email MUST be unique) If Not (objRS.EOF And objRS.BOF) Then objRS.Close Set objRS = Nothing objConn.Close Set objConn = Nothing Session("AcctName") = Request.Form("email") Response.Redirect "error.asp?error=dupacct" Else objRS.Close objRS.Open "Students", objConn, adOpenDynamic, adLockOptimistic, adCmdTable objRS.AddNew objRS("name") = Request.Form("Last") & ", " & Request.Form("First") objRS("classtype") = Request.Form("CIS40or41") objRS("teacher") = Request.Form("Teacher") objRS("meetday") = Request.Form("MeetDay") objRS("email") = Request.Form("Email") objRS("password") = Request.Form("Password") objRS("lastlogin") = "Never Logged In" objRS("active") = False objRS("created") = CStr(Date) objRS("security") = vbStudent 'Student access by default 'Access the Teacher's record so we can get the teacher's email sSQL = "SELECT * From Students Where Name = '" & objRS("teacher") & "'" Set objRSTeacher = Server.CreateObject("ADODB.Recordset") objRSTeacher.Open sSQL, objConn, adOpenDynamic, adLockOptimistic, adCmdText objRS("teacheremail") = objRSTeacher("email") objRSTeacher.Close Set objRSTeacher = Nothing 'Email the new account info to the Student Set Mailer = Server.CreateObject("SoftArtisans.SMTPMail") Mailer.FromName = "Guy Campbell" Mailer.FromAddress = "gcampbell@moorparkcollege.edu" Mailer.organization = "Visual Basic - Moorpark College" Mailer.Subject = "Moorpark College -- Visual Basic Student Account Confirmation" Mailer.smtplog = "C:\mysmtplog.txt" Mailer.live = True Mailer.RemoteHost = "sunny.moorpark.cc.ca.us" Mailer.Priority = 3 Mailer.addrecipient Request.Form("First") & " " & Request.Form("Last"), Request.Form("Email") Mailer.bodytext = "Your Visual Basic Account Information has been saved. " & vbCRLF _ & vbCRLF _ & "Name: " & objRS("name") & vbCRLF _ & "EMail: " & objRS("email") & vbCRLF _ & "Password: " & objRS("password") & vbCRLF _ & "Class: " & objRS("classtype") & vbCRLF _ & "Current Status: Disabled" & vbCRLF & vbCRLF _ & "Important: All information is case sensitive." & vbCRLF & vbCRLF _ & "Note: Your Account will be activated within a few days." & vbCRLF _ & "At that time an email will be sent to you to confirm" & vbCRLF _ & "that your account has been activated." & vbCRLF & vbCRLF _ & "Thank You, " & vbCRLF & vbCRLF & "Guy Campbell" & vbCRLF & "gcampbell@moorparkcollege.edu" Mailer.SendMail Mailer.ClearRecipients End If %>New Visual Basic Student Account Created
Account Information Stored: Name: <%=objRS("name")%>