asp 点击按钮后检测用户名存在与否代码
3个回答
2013-08-08
展开全部
你要的应该是注册用户名检测吧。
<%
dim username,rs,sql
username=trim(request("username"))
if username="" then
Response.Write"请填写登陆用户名称![<a href='javascript:window.close()' style='text-decoration: none'>明白,关闭窗口</a>]"
response.end
end if
set rs=server.createobject("adodb.recordset")
sql="select username from [user] where username='"&username&"' "
rs.open sql,conn,1,1
if not rs.eof or not rs.bof then
if trim(rs("username"))=username then
Response.Write"此用户名称已存在,请更换![<a href='javascript:window.close()' style='text-decoration: none'>明白,关闭窗口</a>]"
response.end
end if
else
if trim(rs("username"))<>username then
Response.Write"可以注册此用户名称,请注意填写时要规范![<a href='javascript:window.close()' style='text-decoration: none'>明白,关闭窗口!</a>]"
response.end
end if
end if
rs.close
set rs=nothing%>
<%
dim username,rs,sql
username=trim(request("username"))
if username="" then
Response.Write"请填写登陆用户名称![<a href='javascript:window.close()' style='text-decoration: none'>明白,关闭窗口</a>]"
response.end
end if
set rs=server.createobject("adodb.recordset")
sql="select username from [user] where username='"&username&"' "
rs.open sql,conn,1,1
if not rs.eof or not rs.bof then
if trim(rs("username"))=username then
Response.Write"此用户名称已存在,请更换![<a href='javascript:window.close()' style='text-decoration: none'>明白,关闭窗口</a>]"
response.end
end if
else
if trim(rs("username"))<>username then
Response.Write"可以注册此用户名称,请注意填写时要规范![<a href='javascript:window.close()' style='text-decoration: none'>明白,关闭窗口!</a>]"
response.end
end if
end if
rs.close
set rs=nothing%>
2013-08-08
展开全部
ASP用户登录的代码:
1.connection.asp里的代码是:
<%
set conn=server.createobject("adodb.connection")
conn.open "provider=microsoft.jet.oledb.4.0;data source="&server.MapPath("student.mdb")
%>
2.yanzheng.asp里的代码是:
<!--#include file="connection.asp"-->
<%
dim zhanghao,mima
zhanghao=request("zhanghao")
mima=request("mima")
if zhanghao="" then
%>
<script language=javascript>
alert("帐号为空");
location.href="denglu.asp"
</script>
<% end if %>
<% if mima="" then
%>
<script language=javascript>
alert("密码为空");
location.href="denglu.asp"
</script>
<% end if %>
<%set rs=server.createobject("adodb.recordset")
rs.open "select * from student where zhanghao='"&zhanghao&"'",conn,1,3
if not rs.eof then
if mima=rs("mima") then
session("zhanghao")=zhanghao
Response.write("<script>location.href('index.asp')</script>" )
else
response.write ("<script>alert('用户密码错误');location.href('denglu.asp')</script>")
end if
end if
if rs.eof then
response.write ("<script>alert('用户帐号错误');location.href('denglu.asp')</script>")
end if
set rs=nothing
rs.close
%>
1.connection.asp里的代码是:
<%
set conn=server.createobject("adodb.connection")
conn.open "provider=microsoft.jet.oledb.4.0;data source="&server.MapPath("student.mdb")
%>
2.yanzheng.asp里的代码是:
<!--#include file="connection.asp"-->
<%
dim zhanghao,mima
zhanghao=request("zhanghao")
mima=request("mima")
if zhanghao="" then
%>
<script language=javascript>
alert("帐号为空");
location.href="denglu.asp"
</script>
<% end if %>
<% if mima="" then
%>
<script language=javascript>
alert("密码为空");
location.href="denglu.asp"
</script>
<% end if %>
<%set rs=server.createobject("adodb.recordset")
rs.open "select * from student where zhanghao='"&zhanghao&"'",conn,1,3
if not rs.eof then
if mima=rs("mima") then
session("zhanghao")=zhanghao
Response.write("<script>location.href('index.asp')</script>" )
else
response.write ("<script>alert('用户密码错误');location.href('denglu.asp')</script>")
end if
end if
if rs.eof then
response.write ("<script>alert('用户帐号错误');location.href('denglu.asp')</script>")
end if
set rs=nothing
rs.close
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-08-08
展开全部
用ajax
当点击时候进行查数据库
当点击时候进行查数据库
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询