<%Option Explicit%> <% dim CONN, RECORDSET, SQL dim Action, text dim Login, ActiveSession dim strID, strLAST, strFIRST, strMI, strTitle, strDivision dim strDepartment, strOffice, strPhone, strEmail, strWebSite dim strLogin, strPassword dim blnDIS, blnSTART, blnUSEFIRST, blnFOUND dim ID Action = request.querystring("ActionType") 'If user has active session variable, means they have successfully logged in 'in previous ten minutes. Otherwise, start from scratch, with action = "" if Action = "" and session("ActiveSession") = "xyz123abc456uvw789rst012" then Action = "Loginsuccess" end if 'Login starts here, with action being empty if Action = "" then %>







Login
Password
<% elseif Action = "Login" then strLogin = request.form("User") strPassword = request.form("Pass") 'Sets connection and recordset object variables to current database settings Set CONN = Server.CreateObject("ADODB.Connection") CONN.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\\brink-premfs1\sites\premium3\williamnewman\database\billnewman.mdb" 'Statement to select any record with matching email and password fields SQL = "SELECT * from Clubs where Login='"& strLogin &"' and Password = '"& strPassword &"'" CONN.OPEN "billnewman" 'Opens connection with database named "Store" RECORDSET.OPEN SQL,CONN 'opens recordset, reads statement "sql" and acts on active connection "conn" if not (RECORDSET.eof)then do while not RECORDSET.EOF Response.write "
" Response.Write "







" Response.Write "
" Response.Write "
" Response.Write "Login successful" Response.Write "" Response.Write "" Response.Write "
Login
" Response.Write "
" Response.Write "
" RECORDSET.MoveNext loop 'Sets action to proceed action = "Loginsuccessful" 'Sets session variable to specific (arbitrary) string. 'Will allow user to remain logged in for 10 minutes, if inactive. session("ActiveSession") = "xyz123abc456uvw789rst012" else 'If no match, inform user Response.Write "







" Response.Write "
" Response.Write "
" Response.Write """Login or Password are incorrect.""

" Response.Write "Try Again?
" Response.Write "
" end if RECORDSET.Close 'Closes recordset CONN.Close 'Closes connection set RECORDSET = nothing 'Removes recordset from memory set CONN = nothing 'Removes connection from memory elseif Action = "Loginsuccess" then %>
ADD  EDIT  DELETE 

<% elseif Action = "Add" then %>
Last Name
First Name
Middle Initial
Title
Division
Department
Office
Phone
Email
WebSite
<% elseif Action = "AddFinal" then 'Inputs info to database Set CONN = server.CreateObject("ADODB.connection") Set RECORDSET = server.CreateObject("ADODB.recordset") CONN.Open "saranewman" RECORDSET.Open "Staff", CONN, , 3, 2 'Adds new record RECORDSET.AddNew RECORDSET("LName") = request.form("LAST") RECORDSET("FName") = request.form("FIRST") RECORDSET("MI") = request.form("MI") RECORDSET("Title") = request.form("TITLE") RECORDSET("Division") = request.form("DIVISION") RECORDSET("Department") = request.form("DEPARTMENT") RECORDSET("Office") = request.form("OFFICE") RECORDSET("Phone") = request.form("PHONE") RECORDSET("Email") = request.form("EMAIL") RECORDSET("WebSite") = request.form("WEBSITE") RECORDSET.UPDATE RECORDSET.Close set RECORDSET = nothing CONN.Close Set CONN = Nothing 'Informs user of successful input If err.number = 0 then response.write "Your Info has been added to the database" Response.Write "VIEW DATABASE
" Response.Write "EDIT DATABASE
" else response.write err.description end if elseif Action = "Edit" then Set CONN = server.CreateObject("ADODB.connection") Set RECORDSET = server.CreateObject("ADODB.Recordset") CONN.Open "saranewman" SQL = "SELECT * FROM Staff" 'Open recordset, perform SQL logic on active connection RECORDSET.Open SQL, CONN 'Perform logic until no more records (eof) if not RECORDSET.eof then 'Sets up for next form response.write "
" response.write "" response.write "
" response.write "
" else 'Responds to user if nothing to edit response.write "There is nothing in the database." end if 'Closes and releases objects RECORDSET.Close set RECORDSET = Nothing CONN.Close Set CONN = Nothing 'Retrieves input from "EditUpdate" form elseif Action = "EditUpdate" then 'Retrieves specific user to edit ID = request.form("frmID") 'Sets connection, recordset Set CONN = server.CreateObject("ADODB.connection") Set RECORDSET = server.CreateObject("ADODB.Recordset") 'Opens active connection CONN.OPEN "saranewman" 'Selects record that matches unique ID number SQL = "SELECT * FROM Staff where ID = " & ID 'Performs logic SQL on open connection RECORDSET.OPEN SQL, CONN if not RECORDSET.eof then 'Inserts fields from current recordset to form for user to see, 'and edit. %>
First Name: ">
Last Name: ">
Middle Initial: ">
Title: ">
Division: ">
Department: ">
Office: ">
Phone Number: ">
Email: ">
Web Site: ">

<% else response.write "Nothing has been selected" end if RECORDSET.Close set RECORDSET = Nothing CONN.Close Set CONN = Nothing 'Once fields are edited, will make edit to appropriate recordset elseif Action = "EditFinal" then ID = request.form("ID") Set CONN = server.CreateObject("ADODB.connection") Set RECORDSET = server.CreateObject("ADODB.recordset") CONN.OPEN "saranewman" RECORDSET.OPEN "Staff", CONN, , 3, 2 'Initializes variable blnFOUND = false 'Go through records until there is a match, changing blnFOUND to true do until RECORDSET.eof or blnFOUND = true 'Compares recordset field to variable "ID" if match, toggles 'blnFOUND as true if (StrComp(RECORDSET("ID"), ID, vbTextCompare) = 0) then blnFound = true else 'If no match, checks next record RECORDSET.MoveNext end if loop 'If no match, close up if not blnFound = true then RECORDSET.close set RECORDSET = nothing CONN.close set CONN = nothing 'Inform user response.write "No record found" response.end end if 'If match, update recordset fields with form values RECORDSET("FName") = request.form("FIRST") RECORDSET("LName") = request.form("LAST") RECORDSET("MI") = request.form("MI") RECORDSET("Title") = request.form("TITLE") RECORDSET("Division") = request.form("DIVISION") RECORDSET("Department") = request.form("DEPARTMENT") RECORDSET("Office") = request.form("OFFICE") RECORDSET("Phone") = request.form("PHONE") RECORDSET("Email") = request.form("EMAIL") RECORDSET("WebSite") = request.form("WEBSITE") 'Updates record RECORDSET.UPDATE RECORDSET.Close set RECORDSET = nothing CONN.Close Set CONN = Nothing 'If no error, inform user of success If err.number = 0 then response.write "Your Information has been edited.
" Response.Write "VIEW DATABASE
" Response.Write "EDIT DATABASE
" else 'Prints description, if error response.write err.description end if elseif Action = "Delete" then Set CONN = server.CreateObject("ADODB.connection") Set RECORDSET = server.CreateObject("ADODB.Recordset") CONN.Open "saranewman" SQL = "select * from Staff" RECORDSET.OPEN SQL, CONN if not RECORDSET.eof then response.write "
" response.write "" response.write "" response.write "
" else response.write "There is nothing in the database." end if RECORDSET.Close set RECORDSET = Nothing CONN.Close Set CONN = Nothing elseif Action = "DeleteFinal" then ID = request.form("CustID") Set CONN = server.CreateObject("ADODB.connection") CONN.Open "saranewman" SQL = "Delete * FROM Staff WHERE ID=" & ID CONN.EXECUTE SQL CONN.Close Set CONN = Nothing 'Informs user If err.number = 0 then response.write "The information has been deleted." Response.Write "VIEW DATABASE
" Response.Write "EDIT DATABASE
" else response.write err.description end if end if %>