Forum Moderators: open
<!-- #include virtual="/libs/lib_header.asp" -->
<!-- #include virtual="/Include/header2.asp" -->
<br>
<%
Dim SectionId, iCounter
Dim cnMilad, rsRst, strSQL
Set cnMilad = Server.CreateObject("ADODB.Connection")
cnMilad.CursorLocation = 3
cnMilad.Open Application("dbConString")
Dim UserName, Password, Flag
' Get the UserName & Password
UserName = Request("UserName")
Password = Request("Password")
If UserName = "" Then
Response.Redirect "/"
End If
If Len(Trim(UserName)) > 0 Then
strSQL = "SELECT SubscriberId, SubscriberEndDate " & _
"FROM NewSubscribers WHERE " & _
"(SubscriberUserName = N'" & UserName & "') AND " & _
"(SubscriberPassword = N'" & Password & "') And Freezed = 0"
Set rsRst = cnMilad.Execute(strSQL)
If rsRst.Recordcount = 1 Then
' Check If User Is Not Expired
If rsRst("SubscriberEndDate") > Date Then
' Store The Subscriber Information
Session("IsLogged") = True
Session("SubId") = rsRst("SubscriberId")
Flag = "SUCCESS"
Else
Flag = "EXPIRED"
End If
Else
Flag = "FAILED"
End If
Else
Flag = "FAILED"
End If
If Flag = "SUCCESS" Then
Response.Redirect "/My/"
ElseIf Flag = "EXPIRED" Then
%>
<Table align="center">
<tr>
<td>
<font face="Tahoma, Arial" size=3 >
<a href="/Registration/indextest.asp?UserName=<%= UserName%>">Your Subscription has Expired with Milad, Do you Want to Renew</a>
</font>
</td>
</tr>
</Table>
<br>
<%
Else
%>
<br>
<TABLE align=center>
<TR>
<TD><FONT face="Tahoma, Arial" size=3>Please Make Sure of Your User Name & Password..!</FONT> <BR>
<p><FONT face="Tahoma, Arial"
size=2>
</p>
<CENTER><A href="/index.asp"><B>Back</B></A></CENTER></td></tr>
<tr>
<td>
<CENTER>
<A href="/LostPassword.asp"><FONT color=red
face="Tahoma, Arial"
size=2>Did You forgot Your Password...?</FONT></A></CENTER>
</TD></TR>
</TABLE>
<br>
<%
End If
Set rsRst = Nothing
cnMilad.Close
Set cnMilad = Nothing
%>
<!-- #include virtual="/include/footer2.asp" -->
<!-- #include virtual="/libs/lib_footer.asp" -->
<p> </p>
Thanks SRazi.
[edited by: rogerd at 8:36 pm (utc) on Sep. 25, 2004]
[edit reason] No URLs please... [/edit]
What I don't see in your code is your method of flipping the switch on the lock once you've determined that your user is logged in.
If Flag = "SUCCESS" Then Rem - Before re-routing the user, set the lock...
updateSql = "UPDATE NewSubscribers SET Freezed = 1 WHERE SubscriberUserName = blah AND SubscriberPassword=BlahBlah"
Rem - Execute your sql string....
Rem - Route the user...
Response.Redirect "/My/"
your on the right track... append your users table with an [active] column of type int that will be updated to true 1 (logged in) or false 0 (logged out).
Once your user is logged in the run the update script:
updateSql = "UPDATE NewSubscribers SET active= 1 WHERE SubscriberUserName = blah AND SubscriberPassword=BlahBlah"
Your new login script would look something like this:
strSQL = "SELECT SubscriberId, SubscriberEndDate " & _
"FROM NewSubscribers WHERE " & _
"(SubscriberUserName = N'" & UserName & "') AND " & _
"(SubscriberPassword = N'" & Password & "') And Freezed = 0 " & _
"AND active <> 1"
A cleaner approach would be to stuff the login & lock script into a single stored procdure that returned the elements that your currently pulling from the RecordSet Object.
Of course you need to update the last activity date and time field every time the user goes to a new page under the same session.