欢迎光临
我们一直在努力

会员管理系统中会员类的实现-ASP教程,ASP应用

建站超值云服务器,限时71元/月

第一:数据库设计:(数据库为access)

会员信息表user_info

字段

说明

类型(长度)

备注

id

会员标识

自动编号

自增长

user_name

用户名

文本

user_password

密码

文本

question

密码提示问题

文本

answer

答案

文本

name

称呼

文本

sex

性别

文本

birthday

出生年月

日期型

region

地区

文本

city

城市

文本

address

地址

文本

phone

电话

文本

email

e-mail

文本

ciertified

是否认证

文本

ctype

会员类型

文本

user_grade

会员等级

文本

二:代码实现:

<%

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

定义用户类

class user_info

dim id,user_name,user_password,question,answer,name,sex,birthday,region,city,address

dim phone,email,ciertified,ctype,user_grade

类初始化

private sub class_initialize

id = 0

user_name = ""

user_password = ""

question = ""

answer = ""

name = ""

sex = ""

birthday = "1910-01-01"

region = ""

city = ""

address = ""

phone = ""

email = ""

ciertified = "否"

ctype = "普通会员"

user_grade = "铜牌"

end sub

加载用户信息

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

检测用户是否存在数据库中

返回值:true存在,false不存在;

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

登录时判断用户密码是否正确

返回值:true正确,false返回

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

添加新用户

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 & ","

strsql = strsql & user_password & ","

strsql = strsql & "" & question & ","

strsql = strsql & "" & answer & ","

strsql = strsql & "" & name & ","

strsql = strsql & "" & sex & ","

strsql = strsql & "#" & birthday & "#,"

strsql = strsql & "" & region & ","

strsql = strsql & "" & city & ","

strsql = strsql & "" & address & ","

strsql = strsql & "" & phone & ","

strsql = strsql & "" & email & ","

strsql = strsql & "" & ciertified & ","

strsql = strsql & "" & ctype & ","

strsql = strsql & "" & user_grade & ")"

response.write strsql

conn.execute (strsql)

add = true

end function

用户修改资料

public sub update()

dim strsql

if id = 0 then

exit sub

end if

strsql = "update user_info set user_password=" & user_password & ""

strsql = strsql & ",question=" & question & ""

strsql = strsql & ",answer=" & answer & ""

strsql = strsql & ",birthday=#" & birthday & "#"

strsql = strsql & ",sex=" & sex & ""

strsql = strsql & ",region=" & region & ""

strsql = strsql & ",city=" & city & ""

strsql = strsql & ",address=" & address & ""

strsql = strsql & ",phone=" & phone & ""

strsql = strsql & ",email=" & email & ""

strsql = strsql & ",ciertified=" & ciertified & ""

strsql = strsql & ",ctype=" & ctype & ""

strsql = strsql & ",user_grade=" & user_grade & ""

strsql = strsql & " where id =" & id

conn.execute(strsql)

end sub

删除用户

public sub delete()

dim strsql

if isexist = true then

strsql = "delete from user_info where user_name=" & user_name & ""

conn.execute(strsql)

id = 0

end if

end sub

类终结

private sub class_terminate

end sub

end class

%>

不是很完善,请大家指点.

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 会员管理系统中会员类的实现-ASP教程,ASP应用
分享到: 更多 (0)

相关推荐

  • 暂无文章