%
Option Explicit
Dim strError, strSQL, objRS
'see if the form has been submitted
If Request.Form("action")="login" Then
'the form has been submitted, so check if a email has been entered
If Request.Form("email") = "" Then strError = strError & "- Please enter a email.
" & vbNewLine
'check if a password has been entered
If Request.Form("password") = "" Then strError = strError & "- Please enter a password.
" & vbNewLine
'// check if an error has occured
If strError = "" Then
'continue include database connection code
%>
<%
'// create the SQL
strSQL = "SELECT id,password, name, regDate FROM tblMembers WHERE email='" & fixQuotes(Request.Form("email")) & "'"
'// run the SQL
Set objRS = objConn.Execute (strSQL)
'// see if there are any records returned
If objRS.EOF Then
'no email found
strError = "- Invalid email or password
" & vbNewLine
Else
'check password
If objRS("password")=Request.Form("password") Then
'email/password valid so save session data
Session("loggedin") = True
Session("userid") = objRS("id")
Session("username") = objRS("name")
Session("regDate") = objRS("regDate")
'if Donna logs in, change her registration date so that it never expires
if Session("userid") = 1 then
Dim str1, str2, str3, datestrs
str1 = month(date)
str2 = day(date)
str3 = year(date)
datestrs = str3 & "-" & str1 & "-" & str2
strSQL = "UPDATE tblMembers SET regDate = '" & datestrs & "' WHERE id = '" & Session("userid") & "' "
objConn.Execute strSQL
Session("regDate") = datestrs
end if
'redirect to members area
Response.Redirect ("MemberOnly.asp?")
Response.End
Else
'invalid password
strError = "- Invalid email or password
" & vbNewLine
End If
End If
End If
If strError <> "" Then
'output the error message
'add extra HTML...
strError = "
The following errors occured:" & _
"
" & vbNewLine & strError
End If
End If
Function fixQuotes(strData)
fixQuotes = Replace(strData,"'","''")
End Function
're-set session data (ie log out)
Session("loggedin")=""
Session("userid")=""
Session("username")=""
Session("regDate")=""
%>
![]() |
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|