代码不能正常显示?
<%'如果尚没有定义passed对象,则将定义为false,表示没有通过身份验证
if isempty(session("passed")) then
session("passed")=false
end if
'如果session(“passed”=false)则表示没有通过身份验证
if session("passed")=false then
username=request.Form("username")
userpwd=request.Form("userpwd")
if username="" then
errmsg="请输入用户名和密码"
else
set adocon=server.createobject("adodb.connection")
adocon.Open"Driver={SQL Server};Server=(Local);UID=sa;PWD=sa;"& _
"database=username;"
set rs=server.CreateObject("adodb.recordset")
sql= "select * from userman where username='"& username &"'"
response.Write(sql)
rs.open sql,adocon,1,3
if rs.eof then
errmsg="用户不存在"
else
if userpwd<>rs.fields("userpwd") then
errmsg="密码不正确"
else
errmsg=""
session("passed")=true
session("username")=rs.fields("username")
session("showname")=rs.fields("showname")
end if
end if
end if
end if
if not session("passed") then
%>
<html>
<head>
<title>用户名和密码</title>
</head>
<body>
<script language="javascript">
function chkfields(){
if(document.myform.username.value==""){
window.alert("请输入用户名!")
return false}
return true
}
</script>
<p>身份验证</p>
<p><%=errmsg%></p>
<form method="post" ation="<%=request.ServerVariables("PATH_INF")%>" name="myform" onsubmit="return chkfield()">
<p>用户名:<input type="text" name="username" size="20"></p>
<p>密码:<input type="password" name="userpwd" size="20"></p>
<p><input type="submit" value="提交" name="b1"><input type="reset" value="全部重写" name="b2"><p>
</form>
</body>
</html>
<%
response.End
end if
%>
程序代码:
<% '如果尚没有定义passed对象,则将定义为false,表示没有通过身份验证 if isempty(session("passed")) then session("passed")=false end if '如果session(“passed”=false)则表示没有通过身份验证 if session("passed")=false then username=request.Form("username") userpwd=request.Form("userpwd") if username="" then errmsg="请输入用户名和密码" else set adocon=server.createobject("adodb.connection") adocon.Open"Driver={SQL Server};Server=(Local);UID=sa;PWD=sa;"& _ "database=username;" set rs=server.CreateObject("adodb.recordset") sql= "select * from userman where username='"& username &"'" response.Write(sql) rs.open sql,adocon,1,3 if rs.eof then errmsg="用户不存在" else if userpwd<>rs.fields("userpwd") then errmsg="密码不正确" else errmsg="" session("passed")=true session("username")=rs.fields("username") session("showname")=rs.fields("showname") end if end if end if end if if not session("passed") then %> <html> <head> <title>用户名和密码</title> </head> <body> <script language="javascript"> function chkfields(){ if(document.myform.username.value==""){ window.alert("请输入用户名!") return false} return true } </script> <p>身份验证</p> <p><%=errmsg%></p> <form method="post" ation="<%=request.ServerVariables("PATH_INF")%>" name="myform" onsubmit="return chkfield()"> <p>用户名:<input type="text" name="username" size="20"></p> <p>密码:<input type="password" name="userpwd" size="20"></p> <p><input type="submit" value="提交" name="b1"><input type="reset" value="全部重写" name="b2"><p> </form> </body> </html> <% response.End end if %>