查看: 2821|回复: 1

[问与答] 访问二个数据库表,访问第一个数据库表验证是否是会员,如果是访问第二个数据表注册

[复制链接]
康大大 发表于 2015-9-15 09:18:11 | 显示全部楼层 |阅读模式
<%
dim UserName,uname,Password,PwdConfirm,Question,Answer,Email,Receiver,Phone,Fax
UserName=Server.HTMLEncode(request("UserName"))
uName=Server.HTMLEncode(request("uName"))
Password=Server.HTMLEncode(request("Password"))
PwdConfirm=Server.HTMLEncode(request("PwdConfirm"))
Question=Server.HTMLEncode(request("Question"))
Answer=Server.HTMLEncode(request("Answer"))
Email=Server.HTMLEncode(request("Email"))
Receiver=Server.HTMLEncode(request("Receiver"))
Phone=Server.HTMLEncode(request("Phone"))
Mobile=Server.HTMLEncode(request("Mobile"))
Fax=Server.HTMLEncode(request("Fax"))
if UserName="" or strLength(UserName)>14 or strLength(UserName)<4 then
founderr=true
errmsg=errmsg & "<br><li>请输入用户号(不能大于8小于4)</li>"
else
  if Instr(UserName,"=")>0 or Instr(UserName,"%")>0 or Instr(UserName,chr(32))>0 or Instr
(UserName,"?")>0 or Instr(UserName,"&")>0 or Instr(UserName,";")>0 or Instr(UserName,",")>0 or Instr
(UserName,"'")>0 or Instr(UserName,",")>0 or Instr(UserName,chr(34))>0 or Instr(UserName,chr(9))>0 or
Instr(UserName,"")>0 or Instr(UserName,"$")>0 then
errmsg=errmsg+"<br><li>用户号中含有非法字符</li>"
founderr=true
end if
end if
if Password="" or strLength(Password)>12 or strLength(Password)<6 then
founderr=true
errmsg=errmsg & "<br><li>请输入密码(不能大于12小于6)</li>"
else
if Instr(Password,"=")>0 or Instr(Password,"%")>0 or Instr(Password,chr(32))>0 or Instr
(Password,"?")>0 or Instr(Password,"&")>0 or Instr(Password,";")>0 or Instr(Password,",")>0 or Instr
(Password,"'")>0 or Instr(Password,",")>0 or Instr(Password,chr(34))>0 or Instr(Password,chr(9))>0 or
Instr(Password,"")>0 or Instr(Password,"$")>0 then
errmsg=errmsg+"<br><li>密码中含有非法字符</li>"
founderr=true
end if
end if
if PwdConfirm="" then
founderr=true
errmsg=errmsg & "<br><li>请输入确认密码(不能大于12小于6)</li>"
else
if Password<>PwdConfirm then
founderr=true
errmsg=errmsg & "<br><li>密码和确认密码不一致</li>"
end if
end if
if Question="" then
founderr=true
errmsg=errmsg & "<br><li>密码提示问题不能为空</li>"
end if
if Answer="" then
founderr=true
errmsg=errmsg & "<br><li>密码答案不能为空</li>"
end if
if Email="" then
founderr=true
errmsg=errmsg & "<br><li>Email不能为空</li>"
else
if IsValidEmail(Email)=false then
errmsg=errmsg & "<br><li>您的Email有错误</li>"
   
founderr=true
end if
end if
if Phone="" then
founderr=true
errmsg=errmsg & "<br><li>联系电话不能为空</li>"
end if
set conn1=server.CreateObject("adodb.connection")
set conn2=server.CreateObject("adodb.connection")
conn1.open "driver={SQL Server};server=192.160.0.20;uid=web;pwd=1Qaz2wsx;database=gas"
conn2.open "driver={SQL Server};server=(local);uid=web;pwd=7951709;database=web"
set rs1=server.CreateObject("recordset")
set rs2=server.CreateObject("recordset")
sql1="select * from view_User "
sql2="select * from [User] "
rs1.open sql1,conn1,1,3
if Mid( UserName,1,1)<>"8"  then

sql="select * from view_User where Userno='" & Username & "' and username='" & uname & "'  "
else
sql="select * from view_User1 where Userno='" & Username & "' and unitname='" & uname & "'  "
end if
if not rs1.eof then
founderr=false
else
errmsg=errmsg & "<br><li>" & UserName & "用户号或人(单位)姓名错误!请确认!
end if
rs1.close
rs2.open sql2,conn2,1,3
if founderr=false then
sql="select * from [User] where UserName='" & Username & "'"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if not(rs.bof and rs.eof) then
founderr=true
errmsg=errmsg & "<br><li>你登记的用户号码已经登记!</li>"
else
rs.addnew
rs("UserName")=UserName
rs("Password")=md5(Password)
rs("Question")=Question
rs("Answer")=md5(Answer)
rs("Email")=Email
rs("Receiver")=Receiver
rs("Phone")=Phone
rs("Mobile")=Mobile
rs("Fax")=Fax
rs("Regdate")=now()
rs.update
founderr=false
end if
rs.close
set rs=nothing
end if
rs2.close
    Set rs1=nothing
    Set rs2=nothing
%>
xuanxiao 发表于 2015-9-17 09:54:38 | 显示全部楼层
14 or strLength(UserName)0 or Instr(UserName,"%")>0 or Instr(UserName,chr(32))>0 or Instr
(UserName ...
康大大 发表于 2015-9-15 09:18

把完整程序和数据库打包,发support@ttasp.com
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表

在线客服

售前咨询
售后咨询
服务热线
023-58418553
微信公众号