一个很简单的代码问题,请高手们帮忙

marysxj 2002-02-05 09:12:10
我的Login.asp 源代码如下,如果成功登陆则转向Myindex.asp(空),数据库内有一个userID = sxj , password = 111的纪录 , 但是我登陆时输入sxj 111,程序不执行,为什么?
<%@ Language=VBScript %>
<%
userID=request("userID")
password = request("password")

if userID<>"" and password <>"" then
set conn = server.CreateObject("adodb.connection")
P1 = "Provider = Mircrosoft.Jet.OLEDB.4.0;"
Path = "Data sourse = " & server.MapPath ("speak.mdb")
conn.Open p1 & Path
Response.Write request("userID")
set rs = server.CreateObject("adodb.recordset")
MySql = "select * from user where userID = userID and password =password "
rs.Open Mysql,conn,1
'Response.Write rs.RecordCount
if rs.RecordCount<> 0 then
session("userID") = userID
Response.Redirect "Myindex.asp"
else
' msgbox "不存在这样的用户或者密码不正确"
end if
else
'msgbox "用户名和密码不能为空",1," 警告"
end if
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY >
<form name = frmLogin method = "post" action = "login.asp">
<table border=0 align=center width="100%" height="100%" cellspacing="0" cellpadding="0">

<TR>
<td align=middle>
<p><b><font color=#786af4 size=5 face="宋体">请您正确登陆后再使用</b></FONT></p>
<table border=0 cellspacing="0" cellpadding="0" height="10%" width="100%">
<TR><td align=center><IMG src="images\manager.gif" ></td></TR></table>
<p></p>
<table border=0>
<tr>
<td ><p ><b><font color=#962424 size = 3>用 户 名:</b></font>  <input type =text name =usreID size =15 maxlength = 15 ></p></td>
</tr>
<tr><p></p></tr>
<tr>
<td><p><b><font color=#962424 size = 3>密    码:</b></font>  <input type=password name=pwd size =15 maxlength = 15></p></td>
</tr>
<tr><p></p></tr>
<tr>
<td align=center><input type ="submit" name ="Buttonsubmit" value ="确定" class = clsMouseOut></td>
</tr>
</table>
</td></TR>
</table>
</form>
</BODY>
</HTML>
<script language = "VBScript">
Sub ButtonSubmit_OnClick
document.frmLogin.submit
End Sub
</script>

问题可能是出在sql语句上,但是我不知道怎么改,请帮忙
...全文
213 28 打赏 收藏 转发到动态 举报
写回复
用AI写文章
28 条回复
切换为时间正序
请发表友善的回复…
发表回复
caichen03 2002-02-16
  • 打赏
  • 举报
回复
1.数据库连接正常
2.sql拼写
3.保证表单提交的数据字段名称和asp数据库字段名称能保持一致
4.不要出现低级拼写错误
编译器提示你的错误就是sql拼写错误,按照楼上的做没错。
marysxj 2002-02-06
  • 打赏
  • 举报
回复
没有人回答了?那我结账了
xglcm 2002-02-05
  • 打赏
  • 举报
回复
SQL语句也要改过来啊你按照yzflying(yanfei) 的方法写。
不会错的啊。
marysxj 2002-02-05
  • 打赏
  • 举报
回复
xglcm(君子爱财取之有道),谢谢你。但是我改成了<input type=password name=password size =15 maxlength = 15>之后还时不执行Myindex.asp呀?
xglcm 2002-02-05
  • 打赏
  • 举报
回复
告诉你吧
request("password")中的password哪里来的啊,是空的啊
与;
<input type=password name=pwd size =15 maxlength = 15>的名字不同啊
所以按照你的代码就不执行了。
以后仔细点
onlysgirl 2002-02-05
  • 打赏
  • 举报
回复
MSGBOX在ASP里不要使用,
marysxj 2002-02-05
  • 打赏
  • 举报
回复
不行,还是不行啊
yzflying 2002-02-05
  • 打赏
  • 举报
回复
..............(表示数据库连接已经建好)
set rs = server.CreateObject("adodb.recordset")
sql = "select * from user where userid = '" & userid & "' and password = '" & password & "'"
rs.open sql 1,1
if rs.eof and rs.bof then
response.write "<script language=javascript>alert('不存在这样的用户或者密码不正确');history.back();</script>"
else
response.redirect"Myindex.asp"
end if
...............
marysxj 2002-02-05
  • 打赏
  • 举报
回复
www525(潮水),不行啊,语句未结束错误 
www525 2002-02-05
  • 打赏
  • 举报
回复
sql语句改为
sql = "select * from user where userid = '" & userid & "' and password = '" & password & "'"

msgbox "不存在这样的用户或者密码不正确" 改为
response.write "<script language=javascript>alert('不存在这样的用户或者密码不正确');history.back();</script>"
或者
response.write "<script language=vbscript>msgbox('不存在这样的用户或者密码不正确')</script>"
www525 2002-02-05
  • 打赏
  • 举报
回复
' msgbox "不存在这样的用户或者密码不正确" 改为
response.write "<script language=javascript>alert('不存在这样的用户或者密码不正确');history.back();</script>"
或者
response.write "<script language=vbscript>msgbox('不存在这样的用户或者密码不正确')</script>"
marysxj 2002-02-05
  • 打赏
  • 举报
回复
guiguai(鬼怪) xuchu(许褚) 
这样还是不行,我没有办法了
我现在还不太懂asp的,说得太深了我也不明白
www525 2002-02-05
  • 打赏
  • 举报
回复
sql = "select * from user where userid = '" & userid & "' and password = '" & password & "'"
guiguai 2002-02-05
  • 打赏
  • 举报
回复
MsgBox是在客户端的,你不是想在服务器屏幕上弹出一个BOX吧??
你的组装脚本发送倒浏览器显示

sql = "select * from user where userid = " & userid & " and password = '" & password & "'"
xuchu 2002-02-05
  • 打赏
  • 举报
回复
rs.Open Mysql,conn,1,1
marysxj 2002-02-05
  • 打赏
  • 举报
回复
xuchu(许褚),按照你说的,还时没有执行
marysxj 2002-02-05
  • 打赏
  • 举报
回复
sql语句应该是没有错误了,但是
if rs.RecordCount<> 0 then
session("userID") = userID
Response.Redirect "Myindex.asp"
这句没有执行
xuchu 2002-02-05
  • 打赏
  • 举报
回复
if not rs.eof then
session("userID") = Rs("userID")
Response.Redirect "Myindex.asp"
Guanghuan 2002-02-05
  • 打赏
  • 举报
回复
SQL语句中的字符变量加单引号。
xuchu 2002-02-05
  • 打赏
  • 举报
回复
MySql = "select * from user where userID ='"& userID &"' and password ='"&password &"'"
加载更多回复(8)

28,406

社区成员

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

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