I wonder if someone can help me....
I have some ASP code which is used so that users can login to a secured section of the website
I have an access database with all the usernames and passwords.
On my main homepage I have two fields Patients ID and Password
when a user clicks on submit the form action address checks an ASP page called "check_user.asp" which has the code below.
It all works perfectly normal, but i'd like to include a remember me checkbox which would allow a user to be remembered the next time they open the page.
Just not sure how it's done and if much work is needed?
I already have some session code placed at the top of the secured pages
<%
'If the session variable is False or does not exsist then redirect the user to the unauthorised user page
If Session("blnIsUserGood") = False or IsNull(Session("blnIsUserG
ood")) = True then
'Redirect to unathorised user page
Response.Redirect"notsigne
din.asp"
End If
%>
this is my check_user.asp code.
<%
'Dimension variables
Dim adoCon 'Database Connection Variable
Dim strCon 'Holds the Database driver and the path and name of the database
Dim rsCheckUser 'Database Recordset Variable
Dim strAccessDB 'Holds the Access Database Name
Dim strSQL 'Database query sring
Dim strUserName 'Holds the user name
'Initalise the strUserName variable
strUserName = Request.Form("txtUserName"
)
'Check the database to see if user exsits and read in there password
'Initialise the strAccessDB variable with the name of the Access Database
strAccessDB = "D:\WWWRoot\domainname.co.
uk\databas
e\database
.mdb"
'Create a connection odject
Set adoCon = Server.CreateObject("ADODB
.Connectio
n")
'Database connection info and driver
strCon = "DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=password
123; DBQ=" & strAccessDB
'Set an active connection to the Connection object
adoCon.Open strCon
'Create a recordset objectj
Set rsCheckUser = Server.CreateObject("ADODB
.Recordset
")
'Initalise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblUsers.Password FROM tblUsers WHERE tblUsers.UserID ='" & strUserName & "'"
'Query the database
rsCheckUser.Open strSQL, strCon
'If the recordset finds a record for the username entered then read in the password for the user
If NOT rsCheckUser.EOF Then
'Read in the password for the user from the database
If (Lcase(Trim(Request.Form("
txtUserPas
s")))) = Lcase(Trim(rsCheckUser("Pa
ssword")))
Then
'If the password is correct then set the session variable to True
Session("blnIsUserGood") = True
'Close Objects before redirecting
Set adoCon = Nothing
Set strCon = Nothing
Set rsCheckUser = Nothing
'Redirect to the authorised user page and send the users name
Response.Redirect"
https://ssl1.lon.gb.securedata.net/domainname.co.uk/authorisedservices.asp?name=" & strUserName
End If
End If
'Close Objects
Set adoCon = Nothing
Set strCon = Nothing
Set rsCheckUser = Nothing
'If the script is still running then the user must not be authorised
Session("blnIsUserGood") = False
'Redirect to the unautorised user page
Response.Redirect"unauthor
isedpage.a
sp"
%>
many thx
Start Free Trial