Jump to content
MakeWebGames

[mccode] online/offline/total users


Tonka

Recommended Posts

i use this on my login page but it can be put anywhere

in login.php find

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

add above

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

then put this wherever you want to display the info

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

Link to comment
Share on other sites

Guest Anonymous

Re: online/offline/total users

Erm, you really don't need a screenie for this...

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

Link to comment
Share on other sites

Guest Anonymous

Re: online/offline/total users

2 queries in each case - count them

However, your version buffers the entire dataset of users, whereas mine just returns a simple integer.

Try running

EXPLAIN SELECT * FROM users;

vs.

EXPLAIN SELECT COUNT(userid) FROM users;

in phpMyAdmin...

EXPLAIN can reveal lots about queries, and give you clues on how to optimize them.

Link to comment
Share on other sites

Guest Anonymous

Re: online/offline/total users

Well I can certainly confirm him asking me for assistance on one occasion...

Anyway, this is getting totally off-topic.

Personally I'd recommend that you never show any data like this on any public facing pages *unless* it is cached. otherwise your site is open to a number of fairly serious issues.

Link to comment
Share on other sites

Re: online/offline/total users

Guess I gonna reply with a small Users Online script that doesn't need MySQL. Not Tested

It's a rude not accurate script, it fetches the IPs and if the same IP isn't listed within 10 minutes it ads it to the txt file.

Now this is a basic example, including the echo, best would be to put the fetch IP into the header and the echo at your login page.

It should work allthough I'm still half asleep

users.php

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

visitors.dat

save a blank file with read/write access called visitors.dat

Link to comment
Share on other sites

Guest Anonymous

Re: online/offline/total users

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

=>

0 users online

1 user online

2 users online

3 users online

4 users online

etc

;)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...