Verify your members
page 3 of 4
by . .
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 24030/ 59

The Code

The code

This is the code that checks the user and sends the email -

Dim objConn, objRS, uname, pword, email, aok, rndnum, objCDO, sqlstatement
uname = LCase(Request.Form("UN"))
pword = LCase(Request.Form("PWD"))
email = LCase(Request.Form("EM"))
Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.RecordSet")
objConn.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=d:\domains\\wisemonk\authuser\users.mdb")
objRS.ActiveConnection = objConn
objRS.Source = "SELECT * FROM users"
objRS.LockType = 3
While Not objRS.EOF
If (objRS.Fields.Item("username").Value = uname) OR (objRS.Fields.Item("email").Value = email) Then
Response.Write("That Username or Email is already in the database")
aok = False
aok = True
End If

If aok = True Then
rndnum = Int(((9521 - 521 + 1) * Rnd) + 521)
With objRS
.Fields("username") = uname
.Fields("password") = pword
.Fields("email") = email
.Fields("status") = "N" & rndnum
End With

Set objCDO = Server.CreateObject("CDONTS.NewMail")
objCDO.To = email

objCDO.From = "Validation Committee on Validating"
objCDO.Subject = "Validate THIS!"
objCDO.Body = "To validate your account go here : http://yoursite/val.asp?e=" & email & "&c=N" & rndnum & vbCrLf & "If the link does not work then remember that your email is " & email & " and your authorization code is N" & rndnum & vbCrLf & "-Validation Committee on Validating"
Set objCDO = Nothing

Response.Write("We send you an email with instructions on how to validate your account")
End If

Set objConn = Nothing
Set objRS = Nothing

Ok, that was quite a bit of code, but here is the explanation of what it does =

  • It first gets all of the information from the form that was submitted.
  • Then opens a database connection to the database and fills a recordset from the database.
  • Next it loops through all of the rows in the recordset looking for any fields that match the username or email address.
  • If none are found then it sets aok to True and continues.
  • If aok is True then it inserts the user into the database. Note that the status is N[random number]. This random number is the authorization code.
  • It then sends an email using CDONTS to the user with the link and the auth code.

The reason for the auth code is so that a user can't just use a false email (eg. and then validate it by going to val.asp? The code is only in the database and in the email sent.

View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2023  |  Page Processed at 2023-09-29 11:52:11 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search