home *** CD-ROM | disk | FTP | other *** search
/ 207.233.110.77 / 207.233.110.77.tar / 207.233.110.77 / vbasic / ForgotPassword.asp < prev    next >
Text File  |  2003-09-18  |  3KB  |  91 lines

  1. <%@ LANGUAGE="VBSCRIPT" %>
  2. <% Option Explicit %>
  3. <!-- METADATA 
  4.    TYPE="TypeLib" 
  5.    FILE="C:\Program Files\Common Files\System\ADO\msado21.tlb" 
  6. -->
  7. <!--#include file="DatabaseConnect.asp"-->
  8. <%
  9. Dim objRS
  10. Dim sSQL
  11. Dim strEmail
  12. Dim Mailer
  13.  
  14. strEmail = Trim(Request.Form("email"))
  15. If strEmail = "" Then
  16. %>
  17.     <FORM METHOD=POST NAME=FindPassword ACTION=ForgotPassword.asp>
  18.         <!--Textbox and Button for FindPassword option-->
  19.         Enter your Visual Basic Student Account Email Address below:<BR><BR>
  20.         Email: <INPUT TYPE=TEXT NAME="email" SIZE="40"><BR><BR>
  21.           <INPUT TYPE=SUBMIT VALUE="Email Me My Password">
  22.         <INPUT TYPE="Button" VALUE="Cancel" onClick="document.location='default.asp';"> 
  23.     </FORM>
  24. <%
  25. Else
  26.     If Not IsValidEmail(strEmail) Then
  27.         Response.Redirect "error.asp?error=findpassword"
  28.     End If
  29.     sSQL = "SELECT * From Students Where email = '" & strEmail & "'"
  30.     Set objRS = Server.CreateObject("ADODB.Recordset")
  31.     objRS.Open sSQL, objConn, adOpenDynamic, adLockOptimistic, adCmdText
  32.     'Make sure the student's account exists
  33.     If Not (objRS.EOF And objRS.BOF) Then 
  34.         'Email their Password to the Student
  35.         Set Mailer = Server.CreateObject("SoftArtisans.SMTPMail")
  36.         Mailer.FromName = "Guy Campbell"
  37.         Mailer.FromAddress = "gcampbell@moorparkcollege.net"
  38.         Mailer.organization = "Visual Basic - Moorpark College"
  39.         Mailer.Subject = "Moorpark College -- Visual Basic Account Information"
  40.         Mailer.smtplog = "C:\mysmtplog.txt"
  41.         Mailer.live = True
  42.         Mailer.RemoteHost = "sunny.moorpark.cc.ca.us"
  43.         Mailer.Priority = 3        
  44.         Mailer.addrecipient objRS("name"), objRS("email")
  45.         Mailer.bodytext = "Here is your Visual Basic Account Password. " & vbCRLF _
  46.                 & vbCRLF _
  47.                 & "Name: " & objRS("name") & vbCRLF _
  48.                 & "Email: " & objRS("email") & vbCRLF _
  49.                 & "Password: " & objRS("password") & vbCRLF & vbCRLF _
  50.                 & "Important:  All information is case sensitive." & vbCRLF & vbCRLF _
  51.                 & "Note: If you did not explicitly request that your password" & vbCRLF _                
  52.                 & "be emailed to you, please let me know immediately by" & vbCRLF _
  53.                 & "emailing me at the address below." & vbCRLF  & vbCRLF _
  54.                 & "Thank You, " & vbCRLF & vbCRLF & "Guy Campbell" & vbCRLF & "gcampbell@moorparkcollege.net"
  55.         Mailer.SendMail                        
  56.         Mailer.ClearRecipients
  57.         Set Mailer = Nothing
  58.         objRS.Close
  59.         Set objRS = Nothing
  60.         objConn.Close
  61.         Set objConn = Nothing
  62.         Response.Write ("<B>An email has been sent to " & strEmail & "<BR>that includes your password information.</B><BR>")
  63.         %>
  64.         <BR><INPUT TYPE="Button" ALIGN="left" VALUE="Continue" onClick="document.location='default.asp';"> 
  65.         <%
  66.     Else
  67.         objRS.Close
  68.         Set objRS = Nothing
  69.         objConn.Close
  70.         Set objConn = Nothing
  71.         Response.Redirect "error.asp?error=noacct"
  72.     End If
  73. End If
  74.  
  75. 'Returns True if an email address is valid
  76. Function IsValidEmail(strEmail)
  77.     Dim bIsValid
  78.     bIsValid = True
  79.     If Len(strEmail) < 5 Then
  80.       bIsValid = False
  81.     ElseIf Instr(1, strEmail, " ") <> 0 Then
  82.       bIsValid = False
  83.     ElseIf InStr(1, strEmail, "@", 1) < 2 Then
  84.       bIsValid = False
  85.     ElseIf InStrRev(strEmail, ".") < InStr(1, strEmail, "@", 1) + 2 Then
  86.         bIsValid = False
  87.     End If
  88.     IsValidEmail = bIsValid
  89. End Function
  90.  
  91. %>