•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 391,163 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,366 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 3045 | Replies: 0
![]() |
| |
•
•
Join Date: Aug 2004
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 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
'===============================
%>
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
'===============================
%>
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb ASP Marketplace
- Textbox is not losing its previous value (ASP.NET)
- Date format in MS Office 2000 (Visual Basic 4 / 5 / 6)
- Access form expression help (Computer Science and Software Design)
- MySql multiple table query problem.... (MySQL)
- phpBB to php-nuke integration help (PHP)
- Query Troubles (ColdFusion)
- IIS connection will not write data (ASP)
Other Threads in the ASP Forum
- Previous Thread: getting email adress from logon_user
- Next Thread: Jscript Replace Function


Hybrid Mode