2013年9月6日 星期五

asp-logon-web-page-sample

global.asa

<SCRIPT LANGUAGE=VBScript RUNAT=Server>
SUB Session_OnStart
  ' This is the default authentication status
  Session("Authenticated") = 0
END SUB
</SCRIPT>


login.asp

<HTML>
<BODY BGCOLOR=FFFFFF>
<FORM ACTION="verify.asp" METHOD=POST>
Name:
<INPUT TYPE=TEXT SIZE=20 NAME=USERNAME>
Password:
<INPUT TYPE=PASSWORD SIZE=20 NAME=USERPASSWORD>
<INPUT TYPE=SUBMIT VALUE="Login Now">
</BODY>
</HTML>



verify.asp

<%
Set Cm = Server.CreateObject("ADODB.Command")
Cm.ActiveConnection = "LoginDSN"
Cm.CommandText = "SELECT * FROM tUsers WHERE " & _
  "UserName='" & Request.Form("UserName") & "' AND " & _
  "UserPassword='" & Request.Form("UserPassword") & "' "

Cm.CommandType = 1

Set Rs = Cm.Execute

If Rs.EOF Then
  Session("Authenticated") = 0
  Response.Redirect ("login.asp")
Else
  Session("Authenticated") = 1
  Response.Redirect ("welcome.asp")
End If
%>




check.inc

<%
If Session("Authenticated") = 0 Then
  Response.Redirect ("Login.asp")
End If
%>


each web page (.asp)

<!-- #include file="check.inc" -->





沒有留言:

張貼留言