连接数据库代码没有写出来.只要把这部分代码写出来,然后把表的名字改成自己需要的,基本上就可以直接用了。由于匆忙,漏了一点东西.:)<%
if Request.Form()="" then Response.write "拒绝访问!" :response.end
who=Trim(request.form("operator"))
passwd=Trim(request.form("passwd"))
if who="" then %>
<script>
<!--
alert("请输入工号!");
window.location.href=history.back(); //返回登陆页面.
-->
</script>
<%end if
if passwd="" then
%>
<script>
<!--
alert("请输入密码!");
window.location.href=history.back();
-->
</script>
<%end if
if who<>"" and passwd<>"" then
sql="select * from operator where operatorID='"&request.form("operator")&"'"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<script>
<!--
alert("工号输入错误!");
window.location.href=history.back();
-->
</script>
<%elseif passwd=rs("passwd") then
session("operatorID")=who '保存用户身份信息,以便下页使用,根据需要可以要,也可以不要
rs.close
set rs=nothing
conn.close
set conn=nothing
response.redirect "default.asp" '通过验证,定向到你要的页面
else
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<script>
<!--
alert("密码错误,你无权登录!");
window.location.href=history.back();
-->
</script>
<%end if
end if
%>
这还不简单,很好写呀!:)给你一个参考.
<%
if Request.Form()="" then Response.write "拒绝访问!" :response.end
who=Trim(request.form("operator"))
passwd=Trim(request.form("passwd"))
if who="" then
'Response.Redirect "error.asp?id=210"%>
<script>
<!--
alert("请输入工号!");
window.location.href=history.back();
-->
</script>
<%end if
if passwd="" then
'Response.Redirect "error.asp?id=128"%>
<script>
<!--
alert("请输入密码!");
window.location.href=history.back();
-->
</script>
<%end if
if who<>"" and passwd<>"" then
sql="select * from operator where operatorID='"&request.form("operator")&"'"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
rs.close
set rs=nothing
conn.close
set conn=nothing
'response.redirect "error.asp?id=253"%>
<script>
<!--
alert("工号输入错误!");
window.location.href=history.back();
-->
</script>
<%elseif passwd=rs("passwd") then
session("operatorID")=who
rs.close
set rs=nothing
conn.close
set conn=nothing
response.redirect "default.asp"
else
'response.redirect "error.asp?id=253"%>
<script>
<!--
alert("密码错误,你无权登录!");
window.location.href=history.back();
-->
</script>
<%end if
end if
%>