ASP验证用户名和密码?哪错了

来源:百度知道 编辑:UC知道 时间:2024/05/28 20:04:29
一下是verify.asp文件
<%
dim Strusername,Strpassword,SQL,rs,conn
Strusername=Trim(request.form("username"))
Strpassword=Trim(request.form("password"))

set conn=Server.createObject("ADODB.Connection")
conn.connectionString="provider=SQLOLEDB.1;data Source=127.0.0.1;Initial Catalog=mysite;UserID=sa;Password="
conn.open

if conn.state=adstateclosed then
response.write "<script>alert('数据库没连接')</script>"
end if

set rs=Server.CreateObject("ADODB.RecordSet")
SQL="select * from [user] where username='"&Strusername&"' and password='"&Strpassword&"'"
rs.open SQL,conn,1,1
if rs.EOF then
response.write "<script>alert('用户名或密码错误,请重新输入')</script>"
else
response.redirect "welcome.asp"

provider=SQLOLEDB.1和provider=SQLOLEDB的问题

SQLOLEDB.1表示指定了引擎版本,而SQLOLEDB则未指定版本,默认使用最新版本

可能你的机器上并没有你所指定的版本的连接引擎,所以会出现错误。

没引用别的文件吗? 怎么会跳到这个页面,是在服务器还是在本地

<%
dim Strusername,Strpassword,SQL,rs,conn
Strusername=Trim(request.form("username"))
Strpassword=Trim(request.form("password"))

set conn=Server.createObject("ADODB.Connection")
conn.connectionString="provider=SQLOLEDB.1;data Source=127.0.0.1;Initial Catalog=mysite;UserID=sa;Password="
conn.open

if conn.state=adstateclosed then
response.write "<script>alert('数据库没连接')</script>"
end if

set rs=Server.CreateObject("ADODB.RecordSet")
SQL="select * from [user] where username='"&Strusername&"' and password='"&Strpassword&"'"
rs.open SQL,conn,1,1
if rs.EOF then