Member Management First: Database design: (Database for access)
Member Information Table User_info
Field
Description
Type (length)
Note
Id
Member identification
Automatic numbering
Self-growth
User_name
User name
Text
User_password
Password
Text
Question
Password hint question
Text
Answer
Answer
Text
Name
Call
Text
Sex
Gender
Text
Birthday
Date of birth
Date type
Region
Area
Text
City
City
Text
Address
Address
Text
Phone
Phone
Text
Email
E-Mail
Text
Ciertified
is certified
Text
CType
Member Type
Text
User_grade
Membership level
Text
Two: Code implementation:
<%
Dim conn,connstring,dbfile
Dbfile=server. MapPath ("/database/db.mdb")
Set Conn = Server.CreateObject ("ADODB. Connection ")
' connstring = ' provider=microsoft.jet.oledb.4.01;data source= ' & DBFile
connstring = "Driver={microsoft Access Driver (*.mdb)}; Dbq= "& DBFile
Conn.Open connstring
' Define user class
Class User_info
Dim id,user_name,user_password,question,answer,name,sex,birthday,region,city,address
Dim Phone,email,ciertified,ctype,user_grade
' Class initialization
Private Sub Class_Initialize
ID = 0
user_name = ""
User_password = ""
Question = ""
Answer = ""
Name = ""
Sex = ""
Birthday = "1910-01-01"
Region = ""
City = ""
Address = ""
Phone = ""
Email = ""
ciertified = "No"
CType = "Ordinary Member"
User_grade = "Bronze Medal"
End Sub
' Load User Information
Public Sub Load (ByVal UserName)
Dim rs,sql
sql = "SELECT * from User_info Where user_name= '" & UserName & "'"
Set RS =conn.execute (SQL)
If not (RS.BOF and rs.eof) then
id = RS ("id")
user_name = RS ("user_name")
User_password = RS ("User_password")
Question = RS ("question")
Answer = RS ("Answer")
Name = RS ("Name")
Sex = RS ("Sex")
Birthday = rs ("Birthday")
Region = RS ("Region")
City = RS ("city")
Address = RS (' address ')
Phone = RS ("Phone")
email = RS ("email")
Ciertified = RS ("ciertified")
CType = RS ("CType")
User_grade = RS ("User_grade")
End If
Rs.close
Set rs = Nothing
End Sub
' Detect if a user exists in a database
' Return value: True exists, false does not exist;
Public Function isexist ()
Dim Rs,sql,flag
sql = "SELECT * from User_info Where user_name= '" & User_name & "'"
Set rs = conn.execute (SQL)
If not (RS.BOF and rs.eof) then
Flag = True
Else
Flag = False
End If
Rs.close
Set rs = Nothing
Isexist = Flag
End Function
' Determine if the user password is correct at logon
' Return value: True correctly, FALSE returns
Public Function ispassed ()
Dim Rs,sql,flag
If user_name<> "" and user_password<> "" Then
sql = "SELECT * from User_info where user_name= '" & User_name & "' and User_password= '" & Password & ""
Set rs = conn.execute (SQL)
If not (RS.BOF and rs.eof) then
Flag = True
Else
Flag = False
End If
Rs.close
Set rs = Nothing
Else
Flag = False
End If
ispassed = Flag
End Function
' Add new User
Public Function ADD ()
Dim strSQL
If isexist () = True Then
ADD = False
Exit function
End If
If User_name= "" or user_password= "" or question = "" or Answer = "" Then
ADD =false
Exit function
End If
strSQL = "Insert into User_info (user_name,user_password,question,answer,name,sex,birthday,region,city,address, Phone,email,ciertified,ctype,user_grade) "
strSQL = strSQL & "Values ('" & User_name &