| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 501 人关注过本帖
标题:[求助]这是为什么嘞?
只看楼主 加入收藏
菜鸟先行
Rank: 1
等 级:新手上路
帖 子:157
专家分:0
注 册:2006-1-18
收藏
 问题点数:0 回复次数:4 
[求助]这是为什么嘞?

初学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>

搜索更多相关主题的帖子: 浏览器 nothing 文件夹 false 用户 
2006-01-19 10:58
conn
Rank: 2
等 级:新手上路
威 望:5
帖 子:420
专家分:0
注 册:2005-11-27
收藏
得分:0 

如果仅用来入门的话,你这些代码也太麻烦了吧?
给你一个简单的:
dim txt1,txt2
txt1=request.Form("txt1")
txt2=request.Form("txt2")
if trim(txt1) & "X"="X" or trim(txt2) & "Y"="Y" then
response.Write("<script>alert('<访问被拒绝!>\n用户名和密码都不能为空!');window.history.back();</script>")
response.End()
else
dim rs,sql
set rs=Server.CreateObject("ADODB.RECORDSET")
sql="select * from news_us where name='"&txt1&"'"
rs.open sql,conn,3,3
if rs.recordcount= 0 then
response.Write("<script>alert('<访问被拒绝!>\n用户名不存在');window.history.back();</script>")
response.End()
else
if cstr(rs("pwd"))=cstr(txt2) then
session("control")="******" '<<<<<<<<<<<<<<<-------产生模块变量,用与判断用户是否成功通过验证
response.Redirect("***.asp")
else
response.Write("<script>alert('<访问被拒绝!>\n密码错误!');window.history.back();</script>")
response.End()
end if
end if
end if


我是新手,但我很虚心,对我发的问题请不要取笑,谢谢
2006-01-19 11:28
菜鸟先行
Rank: 1
等 级:新手上路
帖 子:157
专家分:0
注 册:2006-1-18
收藏
得分:0 
以下是引用conn在2006-1-19 11:28:00的发言:

如果仅用来入门的话,你这些代码也太麻烦了吧?
给你一个简单的:
dim txt1,txt2
txt1=request.Form("txt1")
txt2=request.Form("txt2")
if trim(txt1) & "X"="X" or trim(txt2) & "Y"="Y" then
response.Write("<script>alert('<访问被拒绝!>\n用户名和密码都不能为空!');window.history.back();</script>")
response.End()
else
dim rs,sql
set rs=Server.CreateObject("ADODB.RECORDSET")
sql="select * from news_us where name='"&txt1&"'"
rs.open sql,conn,3,3
if rs.recordcount= 0 then
response.Write("<script>alert('<访问被拒绝!>\n用户名不存在');window.history.back();</script>")
response.End()
else
if cstr(rs("pwd"))=cstr(txt2) then
session("control")="******" '<<<<<<<<<<<<<<<-------产生模块变量,用与判断用户是否成功通过验证
response.Redirect("***.asp")
else
response.Write("<script>alert('<访问被拒绝!>\n密码错误!');window.history.back();</script>")
response.End()
end if
end if
end if

呵呵
谢谢前辈指点


笨鸟先飞,菜鸟先行
2006-01-19 13:43
conn
Rank: 2
等 级:新手上路
威 望:5
帖 子:420
专家分:0
注 册:2005-11-27
收藏
得分:0 
呵呵,不客气。编程论坛欢迎ASP爱好者

我是新手,但我很虚心,对我发的问题请不要取笑,谢谢
2006-01-19 13:45
菜鸟先行
Rank: 1
等 级:新手上路
帖 子:157
专家分:0
注 册:2006-1-18
收藏
得分:0 
以下是引用conn在2006-1-19 13:45:00的发言:
呵呵,不客气。编程论坛欢迎ASP爱好者

会常来的


笨鸟先飞,菜鸟先行
2006-01-19 13:48
快速回复:[求助]这是为什么嘞?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015043 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved