home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
207.233.110.77
/
207.233.110.77.tar
/
207.233.110.77
/
vbasic
/
ProcessNewAcct.asp
< prev
next >
Wrap
Text File
|
2003-09-17
|
6KB
|
189 lines
<%@ Language=VBScript %>
<% Option Explicit %>
<!-- METADATA
TYPE="TypeLib"
FILE="C:\Program Files\Common Files\System\ADO\msado21.tlb"
-->
<!--#include file="DatabaseConnect.asp"-->
<html>
<body>
<%
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
%>
<P><B> New Visual Basic Student Account Created</B></P>
Account Information Stored:
Name: <%=objRS("name")%><BR>
Class: <%=objRS("classtype")%> on
<%
Select Case objRS("meetday")
Case "MonWed"
%>
Mondays and Wednesdays during the day.
<%
Case "TueThur"
%>
Tuesdays and Thursdays during the day.
<%
Case "Saturday"
%>
Saturdays during the day.
<%
Case "TueNite"
%>
Tuesday evenings.
<%
Case "WedNite"
%>
Wednesday evenings.
<%
Case "ThurNite"
%>
Thursday evenings.
<%
Case "FriNite"
%>
Friday evenings.
<%
Case Else
'Nothing
End Select
%><BR>
Email: <%=objRS("email")%><BR>
Password: <%=objRS("password")%><BR>
<HR>
Please print this page, or write this information down for future reference.<BR>
An email with the above information has been sent to: <%= " " & objRS("email")%><BR>
Important: When your account is activated, an email telling you so will be<BR>
sent to the above email address (usually within a few days).
<HR>
<INPUT TYPE="Button" VALUE="Finished" onClick="document.location='default.asp';">
<%
objRS.Update
objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
%>
<%
'Returns True if an email address is valid
Function IsValidEmail(strEmail)
Dim bIsValid
bIsValid = True
If Len(strEmail) < 5 Then
bIsValid = False
Else
If Instr(1, strEmail, " ") <> 0 Then
bIsValid = False
Else
If InStr(1, strEmail, "@", 1) < 2 Then
bIsValid = False
Else
If InStrRev(strEmail, ".") < InStr(1, strEmail, "@", 1) + 2 Then
bIsValid = False
End If
End If
End If
End If
IsValidEmail = bIsValid
End Function
'Returns True if a Name contains only A-Z or a-z characters
Function IsAlpha(strName)
Dim bIsAlpha
Dim strChar
Dim i
bIsAlpha = True
'Weed out names that don't use ONLY A-Z or a-z
For i = 1 to Len(strName)
strChar = Asc(Mid(strName, i, 1))
If (strChar < 65 Or strChar > 122) Or _
(strChar > 90 And strChar < 97) Then
bIsAlpha = False
End If
Next
IsAlpha = bIsAlpha
End Function
%>
</body>
</html>