📄 custadd.asp
字号:
<!-- 调用事先定义的config.inc文件 -->
<!-- #include file="config.inc" -->
<%
if request.form("userid")="" then
response.redirect "enroll.asp"
response.end
else
'此函数用来将sql语句中的单引号转换为双引号
function sqlstr(data)
sqlstr="'" & Replace(data,"'","''") & "'"
end function
'用request对象接收变量
userid=trim(request("userid"))
userpw=trim(request("userpw"))
name=trim(request("name"))
idnumber=trim(request("idnumber"))
sex=trim(request("sex"))
age=trim(request("age"))
address=trim(request("address"))
zipcode=trim(request("zipcode"))
email=trim(request("email"))
phone=trim(request("phone"))
'会员联系电话phone字段可以为空,故判断是否为空
'如果为空,则赋值为"没有电话"
if phone="" then phone="没有电话"
'建立数据库连接
set conn=Server.CreateObject("ADODB.Connection")
conn.open connstring
'判断此用户名是否已经存在
set rst=Server.CreateObject("ADODB.Recordset")
rst.activeconnection=conn
sql="select * from users where userid="
sql=sql & sqlstr(userid)
rst.source=sql
rst.open
if Not rst.EOF then
response.write "已经存在此用户名!"
rst.close
response.end
'插入新的会员资料
else
'打印出资料
response.write "<p>"
response.write "<font color=red size=2>您的资料如下:</font><br><hr color=#999933 size=1><br>"
response.write "会员名:" & userid & "<br>"
response.write "密 码: " & userpw & "<br>"
response.write "姓 名:" & name & "<br>"
response.write "身份证:" & idnumber & "<br>"
response.write "性 别:" & sex & "<br>"
response.write "年 龄: " & age & "<br>"
response.write "地 址: " & address & "<br>"
response.write "邮 编:" & zipcode & "<br>"
response.write "电 话: " & phone & "<br>"
response.write "E-Mail: " & email & "<br>"
set rst1=Server.CreateObject("ADODB.Recordset")
rst1.activeconnection=conn
'找到表中custid最大的一个会员
application.lock
sql="select * from users order by custid desc"
rst1.open sql,conn,1,3
if not rst1.eof then
temp=rst1("custid")
temp=right(temp,5)
temp=cint(temp)+1
for i=1 to 5-len(temp)
temp="0"&temp
next
custid="c"&temp
'如果这是要插入的第一个会员,则编号为1
else
custid="C00001"
end if
points=0
'插入一个新的会员
rst1.addnew
rst1("custid")=custid
rst1("userid")=userid
rst1("userpw")=userpw
rst1("name")=name
rst1("idnumber")=idnumber
rst1("sex")=sex
rst1("age")=age
rst1("address")=address
rst1("zipcode")=zipcode
rst1("phone")=phone
rst1("email")=email
rst1("points")=points
rst1.update
application.unlock
response.write "<br><hr color=#999933 size=1><br>"
response.write "<br>您的资料已经注入到我们的系统中,请您<a href=""temp.htm"">继续购物</a><br>,"
response.write "或者您可以现在就<a href=""oldlogin.asp"">登录</a>本网站,享受网上购物的乐趣!"
end if
end if
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -