0

i want to edit the following code so that i can Dlookup 2 tables for my login

and i will like reg_number to be my user name in one table and pin to be my password but in another table
meaning my table structure would be like this ths

1, Table one contains fields names,reg_number,adress,sex i want to use reg_number as my primary key as well as session ID cos it will still be in other tables later
2. Table two contains only one field pin that hold pin numbers for password fields and it should not be used more than 3 times

please i need assistance to restructure the code below to what i just explained above.

Thanks
SOtfmafia.

<%
' login CustomIncludes end
'-------------------------------

'===============================
' Save Page and File Name available into variables
'-------------------------------
sFileName = "login.asp"
sTemplateFileName = "login.html"
'===============================


'===============================
' login PageSecurity begin
' login PageSecurity end
'===============================

'===============================
' login Open Event begin
' login Open Event end
'===============================

'===============================
' login OpenAnyPage Event begin
' 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
'===============================
' Perform the form's action
'-------------------------------
' Initialize error variables
'-------------------------------
sloginErr = ""

'-------------------------------
' Select the FormAction
'-------------------------------
Select Case sForm
Case "login"
loginAction(sAction)
end select
'===============================

'===============================
' Display page
'-------------------------------
' Load HTML template for this page
'-------------------------------
LoadTemplate sAppPath & sTemplateFileName, "main"
'-------------------------------
' Load HTML template of Header and Footer
'-------------------------------
LoadTemplate sHeaderFileName, "Header"
'-------------------------------
SetVar "FileName", sFileName


'-------------------------------
' Step through each form
'-------------------------------
Header_Show
login_Show
'-------------------------------
' Process page templates
'-------------------------------
Parse "Header", False
Parse "main", False
'-------------------------------
' Output the page to the browser
'-------------------------------
Response.write PrintVar("main")

' login Show end

'-------------------------------
' Destroy all object variables
'-------------------------------

' login Close Event begin
' login Close Event end

cn.Close
Set cn = Nothing
UnloadTemplate
'===============================

'===============================
' Login Form Action
'-------------------------------
Sub loginAction(sAction)
sQueryString = GetParam("querystring")
sPage = GetParam("ret_page")
Select case sAction
Case "login"

'-------------------------------
' login Login begin
'-------------------------------
sLogin = GetParam("Login")
sPassword = GetParam("Password")
bPassed = CLng(DLookUp("students", "count(*)", "student_login =" & ToSQL(sLogin, "Number") & " and student_password=" & ToSQL(sPassword, "Number")))

'-------------------------------
' login OnLogin Event begin
' login OnLogin Event end
'-------------------------------
if bPassed > 0 then
'-------------------------------
' Login and password passed
'-------------------------------
Session("UserID") = CStr(DLookUp("students", "reg_number", "student_login =" & ToSQL(sLogin, "Number") & " and student_password=" & ToSQL(sPassword, "Number")))
Session("UserRights") = CLng(DLookUp("students", "sec_level", "student_login =" & ToSQL(sLogin, "Number") & " and student_password=" & ToSQL(sPassword, "Number")))
cn.Close
Set cn = Nothing
if not(sPage = request.serverVariables("SCRIPT_NAME")) and not(isEmpty(sPage)) then
response.redirect(sPage & "?" & sQueryString)
end if
response.redirect("studentsRecord.asp")
else
sloginErr = "Registration Number or Pin Is incorrect."
end if
'-------------------------------
' login Login end
'-------------------------------
Case "logout"
'-------------------------------
' Logout action
'-------------------------------
'-------------------------------
' login Logout begin
'-------------------------------

'-------------------------------
' login OnLogout Event begin
' login 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)
'-------------------------------
' login Logout end
'-------------------------------
End Select
End Sub
'===============================

'===============================
' Display Login Form
'-------------------------------
Sub login_Show()
Dim sFormTitle: sFormTitle = "login"

'-------------------------------
' login Show begin
'-------------------------------

'-------------------------------
' login Open Event begin
' login Open Event end
'-------------------------------
SetVar "FormTitle", sFormTitle
SetVar "sloginErr", sloginErr
SetVar "querystring", GetParam("querystring")
SetVar "ret_page", GetParam("ret_page")
'-------------------------------
' login BeforeShow Event begin
' login BeforeShow Event end
'-------------------------------
if Session("UserID") = "" then
'-------------------------------
' User is not logged in
'-------------------------------
SetVar "LogoutAct", ""
SetVar "UserInd", ""
SetVar "Login", ToHTML(GetParam("Login"))
if sloginErr = "" then
SetVar "loginError", ""
else
SetVar "sloginErr", sloginErr
Parse "loginError", False
End if
Parse "LoginAct", false
else
'-------------------------------
' User logged in
'-------------------------------
SetVar "loginError", ""
SetVar "LoginAct", ""
SetVar "UserID", DLookUp("students", "student_login", "reg_number =" & Session("UserID"))
Parse "UserInd", False
end if
Parse "Formlogin", False

'-------------------------------
' login Close Event begin
' login Close Event end
'-------------------------------

'-------------------------------
' login Show end
'-------------------------------
End Sub
'===============================

%>

1
Contributor
0
Replies
2
Views
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.