<%@ Language=VBScript %>
<%
name = Request.Form("name")
passwd = Request.Form("passwd")
sql = "select name,passwd,type from usertype where name ='" & name & "'"
set conn = server.CreateObject("adodb.connection")
conn.Open Application("dsn")
set rs = server.CreateObject("adodb.recordset")
rs.Open sql,conn
if rs.EOF then
response.write "错误的用户名或密码!"
rs.Close
set rs = nothing
conn.Close
set conn = nothing
Response.End
end if
if not (rs("passwd") = passwd) then
response.write "错误的用户名或密码!"
rs.Close
set rs = nothing
conn.Close
set conn = nothing
Response.End
end if
session("username") = rs("name")
session("usertype") = rs("type")
rs.Close
set rs = nothing
sql = "update visit set visitnum = visitnum +1"
conn.Execute sql
conn.Close
set conn = nothing
Response.Redirect "frame.asp"
%>
在其他过页面加如
<%
if (isempty(session("username")) or len(session("username"))=0) then
Response.Redirect "error.asp"
end if
%>
登陆页identify
<%@ Language=VBScript %>
<%
name = Request.Form("name")
passwd = Request.Form("passwd")
sql = "select name,passwd,type from usertype where name ='" & name & "'"
set conn = server.CreateObject("adodb.connection")
conn.Open Application("dsn")
set rs = server.CreateObject("adodb.recordset")
rs.Open sql,conn
if rs.EOF then
response.write "错误的用户名或密码!"
rs.Close
set rs = nothing
conn.Close
set conn = nothing
Response.End
end if
if not (rs("passwd") = passwd) then
response.write "错误的用户名或密码!"
rs.Close
set rs = nothing
conn.Close
set conn = nothing
Response.End
end if
session("username") = rs("name")
session("usertype") = rs("type")
rs.Close
set rs = nothing
sql = "update visit set visitnum = visitnum +1"
conn.Execute sql
conn.Close
set conn = nothing
Response.Redirect "frame.asp"
%>
在其他过页面加如
<%
if (isempty(session("username")) or len(session("username"))=0) then
Response.Redirect "error.asp"
end if
%>