Date and Time Problem
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > IIS server support > IIS ASP > Date and Time Problem




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Date and Time Problem  
Athmaus


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-26-04 03:19 PM

Hey!

I am making a login program. And i am having a slight problem. THe login wil
l only last for a certain amount of time, right now it is set at two years. 
When the person signs up i have the
Now() function pull the date and time that they signed in.

But in my login script, how can i compare that to make it just two years, (e
ven if it will be off by a few days or so?) I had a function like this writt
en before for an older system, but it doesnt work for this one. Everythign e
lse in the code is working
except for the date validation.

Here is my script:
(ignore the redirects they are just for my testing only, i havent made the r
eal links yet)

<%
Response.Expires = -1000 'Make sure the browser doesnt cache this page
Response.Buffer = True 'enables our response.redirect to work

If Request.Form("valuepassed") ="true" Then
CheckLoginForm
Else
ShowLoginForm
End If

Sub CheckLoginForm
Dim myconn, blnLoggedIn, exceeded, objRS, pass, user, strdate, expired

Set myconn = Server.CreateObject("ADODB.Connection")
myconn.open = "Provider=SQLOLEDB.1;Password=XXX;Persist Security Info=True;U
ser ID=XXX;Initial Catalog=XXX;Data Source=XXX"

user = Request.Form("username")
pass = Request.Form("password")
strdate = DateSerial("1998","12","31")
exceeded = 2

Set objRS = myconn.execute("SELECT site, signup, logged FROM regfreeup WHERE
 username='" & user & "' AND pass='" & pass & "';")

If objRS.EOF Then 'NO RECORDS MATCH. USER DID NOT LOG IN CORRECTLY
blnLoggedIn = False
Response.Redirect "www.microsoft.com"

Else
If objRS("signup") <= strdate Then 'THE TIME DATE IS PAST
blnLoggedIn = False
Response.Redirect "www.gamezone.com"

Else
If objRS("logged") >= exceeded Then 'LOGGED IN AN ABNORMAL TIME
blnLoggedIn = false
Response.Redirect "www.starbucks.com"

Else
If objRS("logged") = 1 Then 'ONLY CAN ACCESS CERTAIN FEATURES
blnLoggedIn = True
myconn.execute("UPDATE regfreeup set logged = (logged + 1), lastlogged = '" 
& Now() & "' WHERE username='" & user & "' AND pass='" & pass & "';")
Response.Redirect "http://www.google.com"

Else 'ACCESS TO EVERYTHING
blnLoggedIn = True
myconn.execute("UPDATE regfreeup set logged = (logged + 1), lastlogged = '" 
& Now() & "' WHERE username='" & user & "' AND pass='" & pass & "';")
Response.Redirect "http://ps2.ign.com"

objRS.Close
Set objRS= Nothing
myconn.Close
Set myconn= Nothing

ShowLoginForm
End If
End If
End If
End If
End Sub
%>







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 08:42 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register