木村拓哉 松隆子 bibi:关于ASP登陆页面!!菜鸟求助
来源:百度文库 编辑:高校问答 时间:2024/10/05 12:03:46
biaodan.html
<form name="form1" action="check.asp" method="post">
用户名:<input type="text" name="user_name"size="8">
密码:<input type="password" name="pass"size="7">
<input type="submit" value="登陆">
<input type="reset" value="重设">
</form>
check.asp
<!--#include file="conn.asp"-->
<%
dim admin_name,admin_pwd
admin_name=trim(request("user_name"))
admin_pwd=trim(request("pass"))
set rs=server.createobject("adodb.recordset")
sql="select * from admin where user='"&admin_name&"'and pwd='"&admin_pwd&"'"
rs.open sql,conn,1,1
%>
<%
if not rs.eof then response.redirect "登陆成功页面"
else
response.redirect"失败页面"
end if
%>
conn.asp
<%
set conn=server.createobject("adodb.connection")
dbpath=server.mappath("mydb.mdb")
conn.open"driver={microsoft access driver (*.mdb)};dbq="& dbpath
%>
还是不行啊!!请各位大侠写好代码写句解释好吗!让我知道错在那,谢谢了!!!我是小菜鸟!
sql=\"select * from [admin] where [user]=\'\"&admin_name&\"\'and [pwd]=\'\"&admin_pwd&\"\'\"
check.asp
<!--#include file="conn.asp"-->
<%
dim admin_name,admin_pwd
admin_name=trim(request("user_name"))
admin_pwd=trim(request("pass"))
set rs=server.createobject("adodb.recordset")
sql="select * from [admin] where user='"&admin_name&"' and pwd='"&admin_pwd&"'"
rs.open sql,conn,1,1
%>
<%
if not rs.eof then
response.redirect "登陆成功页面"
else
response.redirect "失败页面"
end if
%>
biaodan.html
<form name="form1" action="check.asp" method="post">
用户名:<input type="text" name="user_name"size="8">
密码:<input type="password" name="pass"size="7">
<input type="submit" value="登陆">
<input type="reset" value="重设">
</form>
check.asp
<!--#include file="conn.asp"-->
<!--#include file="md5.asp">
<%
dim admin_name,admin_pwd
admin_name=trim(request("user_name"))
admin_pwd=trim(request("pass"))
set rs=server.createobject("adodb.recordset")
sql="select * from admin where user='"&admin_name&"'and pwd='"&md5(admin_pwd)&"'"
rs.open sql,conn,1,1
%>
<%
if not rs.eof then response.redirect "登陆成功页面"
else
response.redirect"失败页面"
end if
%>
conn.asp
<%
set conn=server.createobject("adodb.connection")
dbpath=server.mappath("mydb.mdb")
conn.open"driver={microsoft access driver (*.mdb)};dbq="& dbpath
%>
你是不是忘记写MD5函数了啊 哈哈。。。如果没有MD5函数偶愿意为你提供!
<%
pwd = request.form("pass")
name = request.form("user_name")
Set rs = Server.CreateObject("ADODB.Connection")
sql = "select * from admin where user='" & admin_name & "' And PassWord='"& admin_pwd &"'"
Set rs = conn.Execute(sql)
If Not rs.EOF = True Then
response.redirect "登陆成功页面" Else
Response.Redirect "失败页面"
"
End If
%>
经本人测试,错误很多!!!!
错误出在
1、sql="select * from admin where user='"&admin_name&"'和 and
之间要有空格,
2、if not rs.eof then 后不要直接跟,跟了else就不能用了!
3、数据苦结束语句也没有写、rs 和conn 都要结束 !!
4、response.redirect "登陆成功页面"
怎么用redirect呢?应该是write
改了 就没问题了!!!
sql="select * from [admin] where user='"&admin_name&"'and pwd='"&admin_pwd&"'"
把SQL语句换成这个试试.