Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1

    Default Show users logged into MySQL database

    I have a user system that I made, and I was wondering if anyone knew a PHP code that I could use to display all of the people logged into the MySQL database.

  2. #2
    Join Date
    Oct 2007
    Posts
    824
    Tokens
    71

    Latest Awards:

    Default

    Username hook?
    Vouches
    [x][x]

  3. #3
    Join Date
    Sep 2008
    Posts
    718
    Tokens
    0

    Default

    you mean like a 'Who's Online' type thing?
    +.net - omg it's coming o_o

  4. #4
    Join Date
    Oct 2008
    Location
    In a box, US
    Posts
    306
    Tokens
    0

    Default

    On every login, use the
    PHP Code:
    <? if ($date_logged_online==('(date(D:M:Y - H:M-15))')-->%){ 

    $database --> $array ==> 

    $rowselect['user_name_varible'];

    $online_usr $rowselect['user_nmae_varible'];

    echo 
    "'.$online_usr.' is ONLINE! <br>";

     } else { echo 
    "Your the only one online!"?>
    typa thing? I' poor at PHP, but it works on myne (yes I'm making a usersystem...) I'm assuming your connected to a table and a database... Right?
    It should work, Happy PHP! change "$rowselect" to the variable your using to get info from the database table... . It should show logged in people from the last 15 minutes, enjoy!


    EDIT: $array is the editible variable to the variable ur connecting to table!
    Last edited by D-Man22; 20-10-2008 at 04:37 PM.

  5. #5
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    In your users table, have a lastUpdated field.. on each page in the config.php (which should be called on most pages..) have a checkLogin() function which returns true/false.

    PHP Code:
    if(checkLogin() == true) {
        
    updateUser$username );

    updateUser can just update that field with time(), then just calculate everyone with a lastUpdated field in a period of say.. 15 minutes.

    That should calculate your "users online"

  6. #6
    Join Date
    Aug 2008
    Location
    Surrey
    Posts
    3,111
    Tokens
    1,411

    Latest Awards:

    Default

    Sorry Don't Know about MySQL!
    Jordan


  7. #7
    Join Date
    Sep 2006
    Location
    Evanston, Illinois.
    Posts
    2,361
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Dentafrice View Post
    In your users table, have a lastUpdated field.. on each page in the config.php (which should be called on most pages..) have a checkLogin() function which returns true/false.

    PHP Code:
    if(checkLogin() == true) {
        
    updateUser$username );

    updateUser can just update that field with time(), then just calculate everyone with a lastUpdated field in a period of say.. 15 minutes.

    That should calculate your "users online"
    Exactly how I do it, thanks to you! I remember back in the day, when I used a boolean to represent on and off. Horrifically, illogical.

    @OP: If you mean actual MySQL, as Fazon said use a user login/logout hook.

    Btw, a hook is a script that is run on a specific event.

    Use it to update a text file, as I'm guessing that would be the best way to retrieve it.

    Then your whos online? code should just read off of that text file.
    How could this hapen to meeeeeeeeeeeeeee?lol.

  8. #8
    Join Date
    Jul 2008
    Location
    Hastings, UK.
    Posts
    2,050
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by JordzHere View Post
    Sorry Don't Know about MySQL!
    Now you're just spamming, don't post if you can't contribute.

    Just use a session, and on every page it updates the user status with something like Dentafrice said.

  9. #9
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Quote Originally Posted by Hypertext View Post
    Exactly how I do it, thanks to you! I remember back in the day, when I used a boolean to represent on and off. Horrifically, illogical.

    @OP: If you mean actual MySQL, as Fazon said use a user login/logout hook.

    Btw, a hook is a script that is run on a specific event.

    Use it to update a text file, as I'm guessing that would be the best way to retrieve it.

    Then your whos online? code should just read off of that text file.
    Why the hell write it to a text file? That's pretty illogical, and hooking it on the login/logout.. that's not going to make an accurate "who's online" if you don't update the last activity they did.. that's just going to make it on the login timestamp.

    Sounds pretty "illogical" to me.

  10. #10
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    The only "accurate" way todo it would be with the timestamp within a database, or make the sessions save to a directory (which can be set in php) then use some PHP code to count all sessions which have been active within a certain time, still uses timestamp but it grabs it from the php session files directly.

    I have always done it with a timestamp in a user database, so my second thought could be completly useless.


    www.fragme.co = a project.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •