按钮
代码 : form表名:admininfo
通过REQUESt来设值,再连接数据库从数据库中获取记录集进行查询,如存在就成功,再获得用户SESSION 或COOKIES这样就登录成功如是不成功直接显出警告 给你一串代码,供您参考:dim admin,UserPassword,passcode
admin=FormatSQL(replace(trim(request.form("admin")),"'",""))
UserPassword=md5(FormatSQL(replace(trim(request.Form("UserPassword")),"'","")))if admin="" or UserPassword="" then
response.Write ""
conn.Close
set conn=nothing
response.end
end if
if not isnumeric(request.form("passcode")) then
response.Write ""
conn.Close
set conn=nothing
response.end
end if
passcode=Cint(request.form("passcode"))
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from [admin] where UserPassword='"&UserPassword&"' and admin='"&admin&"' " ,conn,1,1
if rs.bof and rs.eof then
response.write ""
rs.Close
set rs=nothing
conn.Close
set conn=nothing
response.end
else
if passcode<>Session("GetCode") then
response.Write ""
rs.Close
set rs=nothing
conn.Close
set conn=nothing
response.end
end if
if UserPassword=rs("UserPassword") and admin=rs("admin") then
session("admin")=trim(rs("admin"))
session("flag")=trim(rs("flag"))
session("rank")=int(rs("rank"))
session.Timeout=20
response.Cookies("timesshop")("admin")=trim(request.form("admin"))
Response.Cookies("timesshop").Expires = Now()+1
rs.Close
set rs=nothing
conn.Close
set conn=nothing
response.Redirect "../index.asp"
else
response.write ""
rs.Close
set rs=nothing
conn.Close
set conn=nothing
end if
end if
html里面要套用脚本,在htnl标签里面放入这个标签非空验证的话 假如用户名和密码name属性分别是 txtname 和 txtpwdif(document.all.txtname.value=="" ){alert("用户名不能空")}txtname.focus();else if( document.all.txtpwd.value==""){alert("密码不能为空")}txtpwd.focus();
接受前页传过来的值。IF 用户名和密码=你设定的 then Response.Redirect "成功的页面"else失败的页面end if
通过request来判断预设值.