asp中判断用户名已在数据库中存在

asp中判断用户名已在数据库中存在,第1张

试试如下代码:

username = request("username")

if isNull(username) then

username = ""

else

username = Trim(username)

end if

sql="select * from 用户表 where 姓名='"&username&"'"

set rs=server.createobject("adodb.recordset")

rs.open sql,conn,1,3

If rs.BOF And rs.EOF Then

rs.addnew

rs("姓名")=username

rs.update

rs.close

set rs=Nothing

response.write "<script language=javascript>"

response.write " alert('添加信息成功!')"

response.write " window.location='你想返回的页面.asp'"

response.write "</script>"

Else

rs("姓名")=username

rs.update

rs.close

set rs=Nothing

response.write "<script language=javascript>"

response.write " alert('信息修改成功')"

response.write " window.location='你返回的页面地址.asp'"

response.write "</script>"

End If

<%

dim conn,connstr,sql,RS,username

username=Reauest.Form("username")

set conn=server.CreateObject("adodb.connection")

dbpath=server.mappath("data/db.mdb")

connstr="provider=microsoft.jet.oledb.4.0data source="&dbpath

conn.open connstr

set Rs=server.CreateObject("adodb.recordset")

sql="select * from zhuce where username='"&username&"'"

Rs.open sql,conn,1,3

if RS.eof then

Rs.addnew

Rs("username")=request.Form("username")

Rs("sex")=request.Form("sex")

Rs("pwd")=request.Form("pwd")

Rs("company")=request.Form("company")

Rs("postalcode")=request.Form("postalcode")

Rs("telephone")=request.Form("telephone")

Rs("fax")=request.Form("fax")

Rs("email")=request.Form("email")

Rs.update

Rs.Close

conn.close

Set Rs=nothing

set conn=nothing

response.Write("恭喜您注册成功 请现在去登陆吧")

else

Response.Write("用户名存在!")

end if

%>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/9961557.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-03
下一篇 2023-05-03

发表评论

登录后才能评论

评论列表(0条)

保存