<% '------------------------------- ' login CustomIncludes begin %> <% ' login CustomIncludes end '------------------------------- '=============================== ' Save Page and File Name available into variables '------------------------------- sFileName = "EBindex.asp" '=============================== '=============================== ' login PageSecurity begin ' login PageSecurity end '=============================== '=============================== ' login Open Event start ' login Open Event end '=============================== '=============================== ' login OpenAnyPage Event start ' login OpenAnyPage Event end '=============================== '=============================== ' Save the name of the form and type of action into the variables '------------------------------- sAction = GetParam("FormAction") sForm = GetParam("FormName") '=============================== ' login Show begin '=============================== ' Page execution '------------------------------- 'Initialize error variables '------------------------------- sForm1Err = "" '------------------------------- ' Select the FormAction '------------------------------- Select Case sForm Case "Form1" Form1Action(sAction) end select '=============================== '=============================== ' HTML Page layout '------------------------------- %> EB Agenda - Login page
<% Form1_Show %>
<% ' login Show end ' login Close Event start ' login Close Event end '------------------------------- ' Destroy connection object '------------------------------- cn.close Set cn = nothing '=============================== '******************************************************************************** '=============================== ' Login Form Action '------------------------------- Sub Form1Action(sAction) sQueryString = GetParam("querystring") sPage = GetParam("ret_page") Select case sAction Case "login" '------------------------------- ' Form1 Login begin '------------------------------- sLogin = GetParam("Login") sPassword = GetParam("Password") bPassed = CLng(DLookUp("employees", "count(*)", "Login =" & ToSQL(sLogin, "Text") & " and Pass=" & ToSQL(sPassword, "Text"))) '------------------------------- ' Form1 OnLogin Event start ' Form1 OnLogin Event end '------------------------------- if bPassed > 0 then '------------------------------- ' Login and password passed '------------------------------- Session("UserID") = CStr(DLookUp("employees", "IdEmpl", "Login =" & ToSQL(sLogin, "Text") & " and Pass=" & ToSQL(sPassword, "Text"))) Session("UserRights") = CLng(DLookUp("employees", "AC", "Login =" & ToSQL(sLogin, "Text") & " and Pass=" & ToSQL(sPassword, "Text"))) if not(sPage = request.serverVariables("SCRIPT_NAME")) and not(isEmpty(sPage)) then cn.Close Set cn = Nothing response.redirect(sPage & "?" & sQueryString) end if cn.Close Set cn = Nothing response.redirect("EBAgenda.asp") else sForm1Err = "Login or Password is incorrect." end if '------------------------------- ' Form1 Login end '------------------------------- Case "logout" '------------------------------- ' Form1 Logout begin '------------------------------- '------------------------------- ' Form1 OnLogout Event start ' Form1 OnLogout Event end '------------------------------- Session("UserID") = Empty Session("UserRights") = Empty cn.Close Set cn = Nothing if not isEmpty(sPage) then response.redirect(sPage & "?" & sQueryString) response.redirect(sFileName) '------------------------------- ' Form1 Logout end '------------------------------- End Select End Sub '=============================== '=============================== ' Display Login Form '------------------------------- Sub Form1_Show() Dim sFormTitle: sFormTitle = "Login" '------------------------------- ' Form1 Show begin '------------------------------- '------------------------------- ' Form1 Open Event start ' Form1 Open Event end '------------------------------- sQueryString = GetParam("querystring") sPage = GetParam("ret_page") '------------------------------- ' Form1 BeforeShow Event start ' Form1 BeforeShow Event end '------------------------------- %> <% if not (sForm1Err = "") then %> <% end if %> <% if Session("UserID") = "" then '------------------------------- ' User is not logged in '------------------------------- %> <% else '------------------------------- ' User is logged in '------------------------------- UserID = DLookUp("employees", "Login", "IdEmpl =" & Session("UserID")) %> <% end if %>
<%=sFormTitle%>
<%= sForm1Err %>
Login" maxlength="50">
Password
<%= UserID %>
<% '------------------------------- ' Form1 Close Event start ' Form1 Close Event end '------------------------------- '------------------------------- ' Form1 Show end '------------------------------- end Sub '=============================== %>