Click to See Complete Forum and Search --> : login with expiring date problem!!


dante00
06-02-2004, 02:21 PM
I have a login page , when the user logs the code should checks an expiry date which is stored in a Access DB , and if the account has expired it prompts the user and then redirects the user to another page.

I checked in this forum and i found this code

<code>
if rsDate.fields("ExpiryDate").value < Now() then
response.write "Sorry your account has expired"
response.redirect "expired.htm"
end if
<code>

The problem is that i don't really know how to put it in my code!
the following is my code i called the date column in access ExpiryDate

<code>
<%
filePath = Server.MapPath("member/users.mdb")
Set Con = Server.CreateObject("ADODB.Connection")
Con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&filepath
Set oRs = Con.Execute("select * from users where username='"&request.form("username")&"'")

if oRs.eof then
response.redirect"index1.asp?username="&request.form("username")&"&password="&request.form("password")&"&massage=User or password incorrect! "
else
if oRs.fields("passwd")=request.form("password") then
session("secret")="ok"
session("username")=request.form("username")

if rsDate.fields("ExpiryDate").value < Now() then
response.write "Sorry your account has expired"
response.redirect "expired.htm"
end if

'if request.form("remember")="on" then
' response.cookies("usern")="yes"
'response.cookies("usern").expires =now()+365
'response.cookies("username")=request.form("username")
'response.cookies("username").expires =now()+365
'end if

response.redirect"member/member.asp"
else
response.redirect"index1.asp?username="&request.form("username")&"&password="&request.form("password")&"&massage=Password incorrect! "
end if


end if

Con.close
set Con=nothing
set oRs=nothing
%>
<code>


Can someone please help me with that!!!
Thanks in Advance
Yael

simflex
06-02-2004, 03:42 PM
what part of the conditional statement are you having problem with?
You have already used it.
The only little change you need to make is instead of using rsDate, you use oRs.

if oRs.fields("ExpiryDate").value < Now() then
response.write "Sorry your account has expired"
response.redirect "expired.htm"
end if

Just make sure that you have a date field on your database called ExpiryDate and make sure that you are redirecting someone to a page that allows him/her to change his/or her password.

One other note, if you set your expiration date to now() + 365, it will NEVER expire.
That syntax won't work anyway.