初学asp,最近练习时遇到点问题。一个登陆验证,然后根据登陆情况显示控件的代码,主要代码如下,用浏览器运行能出现界面,但点击登陆没反应,没有验证用户,小弟水平很菜,向各位高手求助,谢谢:
-------------------------------------------------------------
com文件夹中的conn.asp文件代码
<%
dim check_flag
check_flag=1
dim connstr
dim conn
dim isconnected
set conn = nothing
isconnected=false
sub open_connection()
if isconnected then
exit sub
end if
constr="driver={sql server};server=localhost;uid=sa;pwd=1234;database=hf"
set conn=server.createobject("adodb.connection")
conn.open constr
isconnected=true
end sub
sub close_connection()
isconnected=false
conn.close
set conn=noting
end sub
%>
主要代码:
。。。。。。。。。。。。
<!--#include file="com/conn.asp"-->
<%
open_connection
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>title</title>
</head>
<body>
<table width="778" align="center" cellpadding="0" cellspacing="0" border="0">
<tr align="center">
<td width="237" align="center">
<table width="237" align="center" cellpadding="0" cellspacing="0" border="0">
<tr width="237" align="center"><td width="237"><img src="Images/denglu_top.jpg"></td>
</tr>
<tr align="center">
<td background="Images/denglu_bottom.jpg" height="123">
<form id="form1" method="post">
<table width="80%" align="center" cellpadding="1" cellspacing="1" border="0">
<tr height="12" align="center"><td width="40%">证件号:</td>
<td width="60%"><input type="text" name="txt_zj" size="15"></td>
</tr>
<tr height="12" align="center"><td width="40%">密码:</td>
<td width="60%"><input type="password" name="txt_pw" size="15"></td></tr>
</table>
<%
sub check_login()
dim zj
dim password
zj=request.Form("txt_zj")
password=request.Form("txt_pw")
if trim(zj) then
response.Write("<script>alert('您输入的证件号不能为空')</script>")
elseif trim(password) then
response.Write("<script>alert('您输入的密码不能为空')</script>")
else
dim rs
dim sqlstr
sqlstr="select user_num,user_password from user"
set rs=Server.CreateObject("adodb.recordset")
rs.open sqlstr,3,3
rs.movefirst
do while not rs.eof and rs.bof
if zj = rs("user_num") then
if password = rs("user_password") then
check_flag=0
else
check_flag=1
response.write "window.location='index.asp'</script>"
end if
else
check_flag=2
response.write "window.location='index.asp'</script>"
end if
rs.movenext
loop
end if
if check_flag=1 then
response.Write "<script>alert('密码错误');"
response.write "window.location='index.asp'</script>"
elseif check_flag=2 then
response.Write "<script>alert('不存在此证件号');"
response.write "window.location='index.asp'</script>"
end if
rs.close
set rs = nothing
end sub
%>
<%
if check_flag=1 or check_flag=2 then
%>
<table width="237" cellpadding="0" cellspacing="0" border="0">
<tr><td width="237" align="center"><input type="image" src="Images/index_denglu.jpg" name="btn_denglu" id="btn_denglu" onClick="check_login()"></td>
</tr>
</table>
<%
elseif check_flag=0 then
%>
<table width="237" cellpadding="0" cellspacing="0" border="0">
<tr><td width="50%" align="center"><a href="houtaudenglu.asp"><img src="Images/index_htdenglu.jpg" border="0"></a></td>
<td width="50%" align="center"><a href="chakanchengji.asp"><img src="Images/index_ckchengji.jpg" border="0"></a></td>
</tr>
<tr><td width="50%" align="center"><a href="zhuxiao"><img src="Images/index_zxdenglu.jpg" border="0"></a></td>
<td width="50%" align="center"><a href="xiugaichengji.asp"><img src="Images/index_xgmima.jpg" border="0"></a></td>
</tr>
</table>
<!--</tr>-->
<%
end if
%>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>