51 users online (1 members and 50 guests)  


  Results 1 to 4 of 4

Related

  1. tracking link clicks    Forum: PHP Forum
    Replies: 15
  2. Domain Forwarding tracking    Forum: General Discussion
    Replies: 1
  3. Domain Forwarding tracking    Forum: Websites For Sale
    Replies: 0
  4. Tracking web forms    Forum: HTML Forum
    Replies: 4
  1. #1
    4mybsa's Avatar
    New User

    Status
    Offline
    Join Date
    Sep 2008
    Location
    Northeast Texas
    Posts
    6

    Need help with tracking # of logins

    I need to know how to write code to make my login page update a new db table colum called # of logins. I need the db table colum to increase by +1 everytime the Registered user logs in to the site. This way I will know how many time that person logged in over time. Here is the code that checks the login information in the db to verify the user is registered. Somewhere in here is were I need it to add value to db table by +1 if login is valid. Can anyone help?

    Code:
    <%@ Language=VBScript %>
      <%  Option Explicit %>
    <!-- #INCLUDE FILE = "adovbs.inc" -->
    <%
    'for an explanation of the above file, see *******
    
       Dim Database, myConn, mySQL, myRS
    
    'Connect to the database access.mdb, table is users
    
       Database="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("_private/accesscustbaseusers.mdb") & ""
       Set myRS=Server.CreateObject("ADODB.Recordset")
       Set myConn=Server.CreateObject("ADODB.Connection")
    
    myConn.Open Database
    
    
    Dim objRS, bolFound, strUserName
    
    ' Set strUserName to the username filled in on the form
    
        strUserName = Request.Form("username")
    
        'make sure username was entered
    
        If strUserName = "" Then
           myConn.Close
           Set myConn = Nothing
        session("myuser")=""
        response.write "<A HREF='login.asp'>"
        response.write("You must enter a Username")
        Response.End
        End If
    
    'open the table users
    
        Set objRS = Server.CreateObject("ADODB.Recordset")
        objRS.Open "Users", myConn, , , adCmdTable
    
        bolFound = False
    
        'look for username the table
    
        Do While Not (objRS.EOF OR bolFound)
           If (StrComp(objRS("UserName"), strUserName, vbTextCompare) = 0) Then
             BolFound = True
           Else
             objRS.MoveNext
           End If
        Loop
    
           'if username is not found, display message
    
        If Not bolFound Then
              objRS.Close
              Set objRS = Nothing
              myConn.Close
              Set myConn = Nothing
              Response.Write "<A HREF='login.asp'>"
              Response.Write "<b>Username is not found Try Again.</b><P>"
              Response.Write "</A>"
              Response.End
           End If
    
           'if passwords do not match, display message
           If Not (StrComp(objRS("Password"), Request.Form("Password"),                    vbBinaryCompare) = 0) Then
              objRS.Close
              Set objRS = Nothing
              myConn.Close
              Set myConn = Nothing
              bolfound=false
              Response.Write "<A HREF='login.asp'>"
              Response.Write "<b>Invalid password Try Again.</b><P>"
              Response.Write "</A>"
              Response.End
           End If
    
    
      Session("myUser")=strUserName
    response.redirect("success.asp")
    
    
        objRS.Close
        Set objRS = Nothing
        myConn.Close
        Set myConn = Nothing
    
    
    
     %>
    Last edited by vinyl-junkie; 09-07-2008 at 11:22 AM. Reason: Added code tags

  2. #2
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: Need help with tracking # of logins

    Add the following just before you set the Session("myUser") variable:

    Code:
    	Set myConn=Server.CreateObject("ADODB.Connection")
    	myConn.Open Database
    	Set myRS=Server.CreateObject("ADODB.Recordset")
    	myRS.Open "event_log", myConn, , adLockOptimistic, adCmdTable
    
    	myRS.AddNew
    	myRS("UserName") = strUserName
    	myRS("date_time") = Now
    	myRS("event") = "Logged In"
    	myRS.Update
    You will also need to create a new table with the following fields:

    UserName (varchar(50)), date_time (varchar(255)), event (varchar(50))

    Call the table: event_log

  3. #3
    4mybsa's Avatar
    New User

    Status
    Offline
    Join Date
    Sep 2008
    Location
    Northeast Texas
    Posts
    6

    Thumbs up Re: Need help with tracking # of logins

    Thank you for the help!. I did what you said and it works great once I linked the the tables together I now have a drop down link for all users that shows the # of loggins and the date and time. Your the man. Again thank you very much for all your help.

  4. #4
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: Need help with tracking # of logins

    Glad I could be of assistance.



Tags for this Thread