高手给看看我写的登陆页面为什么不能用阿!!!

xuezhenlei 2004-04-09 02:04:00
<%@ Language=VBScript %>
<%
name=trim(request("name"))
passwd=trim(request("pwd"))
'检查用户是否输入信息
if name<> "" and passwd<> "" then
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq="& Server.MapPath("kygl.mdb")
set rs= server.createobject("adodb.recordset")
sql="select * from users where id='"&name&"' and pwd='"&passwd&"'"
'检查用户的合法性
Set rs=conn.Execute(sql)
if not(rs.eof) then
msgbox "登陆成功"
else
msgbox " 用户名或密码错误"
end if
else
msgbox "用户名或密码为空"
end if
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>河北大学科研信息管理系统</title>
</head>
<body bgcolor="#808080">
<form name="form1" id="form1"method="post" action="login.asp">
<p> </p>
<p align="center"><font size="7" face="华文行楷">河北大学科研信息管理系统</font></p>
<p align="center"> </p>
<div align="center"></div>
<table width="322" border="1" align="center">
<tr>
<td width="89">用户名:</td>
<td width="217"><input name="user" type="text" value="admin" maxlength="10" size="20"></td>
</tr>
<tr>
<td width="89">密  码:</td>
<td width="217"><input name="pwd" type="password" maxlength="20" size="20"></td>
</tr>
</table>
<div align="center"></div>
<div align="center"></div>
<div align="center"></div>
<p align="center">
<input type="submit" name="login" value="登陆">
 <input type="reset" value="清空" name="clear">
</p>
<p align="center"> </p>
</form>
<hr>
<p align="center">河北大学科技处维护 版权所有</p>
<p align="center">2004-04-22</p>
</body>
</html>
...全文
30 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
luojianfei88 2004-04-11
  • 打赏
  • 举报
回复
conn.open "driver={Microsoft Access Driver(*.mdb)};dbq="&server.mappath(kygl.mdb)
上面这一行代码改为:conn.open 数据库的名称
rs.excute(sqlstr)改为:rs.open sqlstr,conn,1,1
mikespook 2004-04-11
  • 打赏
  • 举报
回复
to andy77(Andy)

-_-! 你汗死我~~~~

SQL INJECTION没必要搞那么神秘吧?
andy77 2004-04-11
  • 打赏
  • 举报
回复
另外,楼主,我顺便提醒你一下。

你这样的登陆页面任何人都可以登陆,而不需要任何用户名和密码。

如果你以前并不知道这种问题,你可以和我联系。andy77@263.net
diveas 2004-04-10
  • 打赏
  • 举报
回复
............不好意思,我发错贴子了。我不是问你的!

sorry
diveas 2004-04-10
  • 打赏
  • 举报
回复
你用的access还是sql?
xuezhenlei 2004-04-09
  • 打赏
  • 举报
回复
login.htm文件如下
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>河北大学科研信息管理系统</title>
<script language=javascript>
function checkform()
{
if (form1.user.value=="")
{
alert("请输入用户名");
form1.user.focus();
return false;
}
else if (form1.pwd.value=="")
{
alert("请输入密码");
form1.pwd.focus();
return false;
}
else
return true;
}
</script>
</head>
<body bgcolor="#808080">
<form name="form1" method="post" action="check.asp" onsubmit="return checkform()">
<p> </p>
<p align="center"><font size="7" face="华文行楷">河北大学科研信息管理系统</font></p>
<p align="center"> </p>
<div align="center"></div>
<table width="322" border="1" align="center">
<tr>
<td width="89">用户名:</td>
<td width="217">
<input name="user" type="text" value="admin" maxlength="10" size="50"></td>
</tr>
<tr>
<td width="89">密  码:</td>
<td width="217">
<input name="pwd" type="password" maxlength="20" size="50"></td>
</tr>
</table>
<div align="center"></div>
<div align="center"></div>
<div align="center"></div>
<p align="center">
<input type="submit" name="login" value="登陆">
 <input type="reset" value="清空" name="clear">
</p>
<p align="center"> </p>
</form>
<hr>
<p align="center">河北大学科技处维护 版权所有</p>
<p align="center">2004-04-22</p>
</body>
</html>
check.asp文件内容如下
<%
dim username,password
username=trim(request("user"))
password=trim(request("pwd"))
if username=""or password="" then
response.write "用户名和密码不能为空"
else
set conn=server.createobject("adodb.connection")
set rs=server.createobject("adodb.recordset")
conn.open "driver={Microsoft Access Driver(*.mdb)};dbq="&server.mappath(kygl.mdb)
sqlstr="select * from users where id='"&username&"' and pwd='"&password&"'"
rs.excute(sqlstr)
if rs.bof=true and rs.eof=true then
response.redirect "login.htm"
else
resopnse.write "dengluchenggong"
end if
end if
%>


请问为什么连接数据库的那段代码不能正常运行呢???????
hermit2003 2004-04-09
  • 打赏
  • 举报
回复
msgbox不能在asp里运行,要用可以放到<% %>标记外边
zwonline99 2004-04-09
  • 打赏
  • 举报
回复
msgbox在服务器上运行是给谁看的?
应该用response.write
skyboy0720 2004-04-09
  • 打赏
  • 举报
回复
name=trim(request.form("user"))

Newrocky 2004-04-09
  • 打赏
  • 举报
回复
不要用MSGBOX 啊!

把要显示的信息用JAVASCRIPT:ALERT("<%=MSG%>")来显示!
benben168 2004-04-09
  • 打赏
  • 举报
回复
<input type=text name=user>
<input type=text name=pwd>
name=trim(request.form("user"))
pwd=trim(request.form("pwd"))
看清楚了!
zyh791211 2004-04-09
  • 打赏
  • 举报
回复
你users表里的id字段是什么类型?能不能和输入的那么对应呢?
还有也同意楼上的说法,msgbox在asp里不能直接用,还要定义它的用法.
用楼上的写法较稳当.呵呵~!
liuyingzi 2004-04-09
  • 打赏
  • 举报
回复
不要用msgbox
要么用javascript :alert
或者 response.write "...."
银狐被占用 2004-04-09
  • 打赏
  • 举报
回复
什么意思?
swich 2004-04-09
  • 打赏
  • 举报
回复
Set rs=conn.Execute(sql)
改为 rs.open sql,conn,3,3

试试
xuezhenlei 2004-04-09
  • 打赏
  • 举报
回复
怎么我的帖子在列表里看不到阿,急

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧