Members in an online community

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hurrajag
Forum Newbie
Posts: 5
Joined: Wed Feb 04, 2004 10:32 am

Members in an online community

Post by hurrajag »

I am making an online-community and I'd like to make the members capable of logging in. The only problem is that I don't have a clue about how to make the MySQL-database able to know if the person is still browsing my site when he is logged in, and also, if you are logged in, who is logged in to that user (IP, so that you only show the functions this person can make to the person that is logged in to that account, so that not all people get access to the functions only the admin is supposed to be able to use)?

I was thinking of using a variable for each members that is "online" 1 or 0 (true or false) then if the person is logged in, you store the IP of the person... then I, again, don't know how to see if the person is still browsing my site...

// HurraJag
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

I don't think that'd be somethign to do with the database. you should look into sessions
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

you're talking about things that cross db (keeping track of last access which lets the other users know if they are recently active.) and php (keeping track of the user)

you could either use cookies and create your own sessions, or use sessions, which is probably easier. however, witht he built in one you cannot manipulate login time, and you have another issue: there are three ways for session to keep track: post/get/cookies
unless you always use post to move around your site, you'll have to use the cookies if you wanna keep it out of your get string
Infinity
Forum Commoner
Posts: 44
Joined: Mon Feb 02, 2004 12:48 pm

Post by Infinity »

If you really want to write your own script ignore this reply.

download phpbb2 plus V1.3 its fully customizable and includes everything you will ever need and is very easy to set up

but you probably wont get the satisfaction that you would get from coding your own :wink:
hurrajag
Forum Newbie
Posts: 5
Joined: Wed Feb 04, 2004 10:32 am

Well...

Post by hurrajag »

Thanks, that is a good idea... I feel that post would be the easiest to use, though is there any way to post variables through a normal <a></a>-link? Or do I have to use the <input type="hidden">-function?

Anyway, this post has helped me a lot already. Thanks again.

// HurraJag
User avatar
Michael 01
Forum Commoner
Posts: 87
Joined: Wed Feb 04, 2004 12:26 am

Post by Michael 01 »

I personally use the hidden function rather than links, and than let the PHP script do the heavy work. Allowing for sessions to be transposed in links can leave for some issues security wise (session swaping) but with it hidden at least, and allowing the php script to handle the brunt of the work, one can assume that unless the person is using the ol source code lookup, the session variables will remain out of sight and most of all, uneditable. (if the script is properly processing the session)
hurrajag
Forum Newbie
Posts: 5
Joined: Wed Feb 04, 2004 10:32 am

Thanks again

Post by hurrajag »

Thank you all, this has helped me a lot and for now I think I will go with the cookie-thingy becuase it feels the most like my level of knowledge, I've only been dealing with PHP for some days and the experience I have is from several other languages like C++ and such, so I can figure out a few ways to make it easier for myself, but this has really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really (I'd like to go on, but you'd get too bored and stop reading) helped me a lot and the cookie-thing works, that is tested and scientifically prooved.
Post Reply