我已经实现了!
谢谢诸位了,我已经实现了!!代码如下:
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/md5.asp" -->
<!--#include file="../inc/conn1.asp" -->
<%
dim username,pwd,corp,addr,mail,tel,num
'变量kong1、kong2为1时,表示当前注册的用户在数据库中已经存在
dim kong1
dim kong2
num=cstr(right(year(date),2))
'format(date,"yyyymmdd")
if month(date)<10 then
num =num + "0" + cstr(month(date))
else
num=num + cstr(month(date))
end if
'num=right(num,6)
if day(date)<10 then
num=num + "0" + cstr(day(date))
else
num =num + cstr(day(date))
end if
randomize
num= "P" + num + cstr(899999*rnd+100000)
'产生的客服号已存在时,重新产生客服号
sql="select servcode from userinfo where servcode ='" & num & "'"
if rs.state then rs.close
rs.open sql,conn,1,1
do while not rs.eof
num=cstr(right(year(date),2))
if month(date)<10 then
num =num + "0" + cstr(month(date))
else
num=num + cstr(month(date))
end if
if day(date)<10 then
num=num + "0" + cstr(day(date))
else
num =num + cstr(day(date))
end if
randomize
num= "P" + num + cstr(899999*rnd+100000)
sql="select servcode from userinfo where servcode ='" & num & "'"
if rs.state then rs.close
rs.open sql,conn,1,1
loop
username=request.form("username")
pwd=MD5(request.form("pwd"))
pwdd=request.Form("pwd")
corp=request.form("corp")
addr=request.form("addr")
mail=request.form("mail")
tel=request.form("tel")
servcode=num
'检测表userinfo中是否存在当前注册用户,存在kong1的值置为1 2004-9-17-wrb
sql="select * from userinfo where name='" & username & "'"
if rs.state then rs.close
rs.open sql,conn,1,1
if not (rs.eof or rs.bof) then
kong1 = 1
end if
'检测表guests中是否存在当前注册的用户,是则变量kong2置为1 2004-9-12-wrb
sql1="select * from guests where guestName='" & username & "'"
if rs1.state then rs1.close
rs1.open sql1,conn1,1,1
if not (rs1.eof or rs1.bof) then
kong2 = 1
end if
if kong1=1 or kong2=1 then
response.write "<script language=JavaScript>" & chr(13) & "alert('此用户已经存在!');"&"history.back()"&" </script>"
else
'向数据库CustServ中写入数据 2004-9-16--WRB
sql="insert into userinfo (name,pwd,corp,addr,mail,tel,servcode) values('"&username&"','"&pwd &"','"&corp&"','"&addr&"','"&mail&"','"&tel&"','"&servcode&"')"
if rs.state then rs.close
conn.Execute(sql)
'向数据库dbmain中写入数据 2004-9-16--WRB
sql1="insert into guests (guestName,pwd,email,tel) values('"&username&"','"&pwdd&"','"&mail&"','"&tel&"')"
if rs1.state then rs1.close
conn1.Execute(sql1)
response.write "<script language=JavaScript>" & chr(13) & "alert('用户注册成功!');"&"window.location.href = 'http://localhost/huaxin/kefu/default.asp'"&" </script>"
response.End
end if
rs.close
set rs=nothing
%>