PHP Login System with Admin Features

This forum was created to talk about the PHP Login System with admin features created by jpmaster77 on evolt's website


    logging users

    Share

    cprompt

    Number of posts : 2
    Registration date : 2008-09-08

    logging users

    Post  cprompt on Mon Sep 08, 2008 2:28 pm

    Greetings all. I am working with this script and I ran into an issue.

    I need to log each time the user logs in and keep track of it. 1, 2,3, etc...

    I have added a field to the USERS table and a function to the database.php:

    Code:

    function updateUserLogins($username,$numLogins){
          $logQuery = "SELECT * FROM users WHERE username = '$username'";
         $logResult = mysql_query($logQuery);
         $num = mysql_numrows($logResult);
         $row = mysql_fetch_array($logResult);
         $numLogins = $row['numLogins'];
         $numLogins = $numLogins + 1;
         $q = "UPDATE ".TBL_USERS." SET numLogins = '$numLogins' WHERE username = '$username'";
         return mysql_query($q, $this->connection);
      }

    And then added a line to the login function of session.php

    Code:

          $database->updateUserLogins($this->username,$numLogins);

    This does increment the database feild each time the user logs in, but then I loose the ability to Register a new user.

    Anyone have an idea as to what I can do?

    Thanks in advance!
    avatar
    Fred-Eric

    Number of posts : 63
    Registration date : 2007-05-13

    Re: logging users

    Post  Fred-Eric on Mon Sep 08, 2008 7:31 pm

    It's because you have add a new field in the user DB so the registration need to be change also with the new field you have add.

    Ex. when the user register add the field numLogins the 0 value during the registration process.

    and Voila

    cprompt

    Number of posts : 2
    Registration date : 2008-09-08

    Re: logging users

    Post  cprompt on Mon Sep 08, 2008 8:15 pm

    So add that field to register.php along with what I have and it should work? Gotcha. I'll give it a go.

    Thanks!
    avatar
    Fred-Eric

    Number of posts : 63
    Registration date : 2007-05-13

    Re: logging users

    Post  Fred-Eric on Mon Sep 08, 2008 10:25 pm

    it is more than just register.php it is only process.php session.php and finally database.php you wil have to do change in all thoses files.

    Sponsored content

    Re: logging users

    Post  Sponsored content


      Current date/time is Tue Dec 11, 2018 4:35 am