Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Displaying A List Of Members Logged In


I wish to display all of the current members who are logged into the system. I figure I can do this using their session id's and matching their usernames accordingly. Or I could create a separate table containing their username and INSERT when someone logs in and DELETE when someone logs out. Then i could display the contents of the table.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Track The Total Number Of Logged In Members
I am currently working on a membership based web site. I need to display the number of members logged in that system. To do this I have set a flag in the database which is set to 1 whenever a user is logged in the system and when the user clicks on the ‘Log Out’ link a query is fired that sets the same flag to 0. To display the total number of logged in members I run a query that counts the number of records whose flag is set to 1.

However this method has a major shortcoming. When users do not click the ‘Log Out’ link but just close the browser. In such a situation the query that will set the flag field back to 0 will bot be fired and hence the user would be seen as active in the system even though the user has already left the system.

When one company is viewing the profile of another company in my site I also need to show whether that representative of the company whose profile is being viewed in logged in the system at that time or not so that if the user wants then can send a message to them.

I need some advice on how can I achieve this in the best possible way, where I can display the total number the total number of correct logged in members..

Displaying Members Edit Profile Page
I have an edit profile page for my memebership system which works fine until i call a function to make sure that the user is logged in before displaying the content with their details.

When I log in and go onto the edit profile page, all the form fields are there but as soon as I click submit the page goes blank.  I don't have this problem if I don't use the function but how else am i supposed to only display the page to registered and logged in users? Code:

Creating A Live/logged On List
Is it possible to determine the currently logged on users? I have a login section of my site that is controlled by sessions and would like to display a list of the currently logged on users.

I did think of creating a 'live' table storing userids and adding/deleting when they login/logout. Logging in is ok, but how do you maintain the list if they just close down without letting me call the relevant unregister session functions?

Displaying List W/out Repeats
I'm working on a project that will allow people to upload content and make entries to a database. I want to build a menu that will display the different values for a certain field, but I know that there will be identical values throughout the table. Do I need to dump values into a separate table, or can I use the values that are there and somehow ignore the repeats?

Displaying Table Field List
I got a function that displays a list of the fields in a certain mysql table.  I got it off of this site.  The problem is that it only displays the word Array and I'm not sure why.  This is the code for the function: Code:

Displaying A List Of Categories From A Database In A Select Box
Could someone please tell me why this outputs nothing

<select name=categories>
<?
$cat_array = get_categories();
foreach($cat_array as $this_cat)
{
echo "<option value="";
echo $this_cat["category_id"];
echo """;
echo ">";
echo $this_cat["category_name"];
echo "
";
}
?>
</select>

==========================================================

function get_categories()
{
//get the list of categories from the database

$conn = mysql_pconnect("localhost", "user", "pwd");
$query = "select * from categories";
$result = mysql_query($query);
if(!$result)
return false;

$num_cats = mysql_num_rows($result);
if($num_cats == 0)
return false;

$result = db_result_to_array($result);
return $result;
}

//A function that returns a query to the database as an array
function db_result_to_array($result)
{
$res_array = array();
for($count=0; $row=@mysql_fetch_array($result); $count++)
$res_array[$count] = $row;

return $res_array;
}

Displaying A List Of All Modules (extensions) Installed
I just signed up for a web hosting service. They have PHP, but can't
tell me which modules (extensions) are installed.

Is there a function, or some other easy way, to show all modules
(extensions) that are installed? phpinfo() doesn't do this.

Displaying Data From Mysql Database In A Drop Down List On Form.
I'm trying to do is display data from two different mysql tables from the same database in a drop down list on a html form. I have a fixtures table with the player1(userid), player2(userid), gameid, game, score1 and 2, what I want is to use the userid to get the players first name and surname from the members table (as it is a unique id), I need to do this bit before displaying it in the drop down. I think i need 2 querys to do this but when I have tried it it just echo's a blank value or the userid not the forname and surname that I want. I'm using the fetch_array function but just can't see where I'm going wrong, Code:

Members Pages On The Fly?
I would like to make a members site, where my members can update their personal page via the web through forums. The pages would be generated by a template. I would also like these member pages to have id=10 so that it is easy to link up.

Members Only Area
Just wondering if you could please please help me with something. I am fairly new to php but have managed to get user input into and out of the my sql database etc. Our site will have a members part to it and I'm not sure how to organize this. I have written a php code which checks a users username and password against what is in the database and sets a cookie for the user if the login info is right.

My quandery (and I can't seem to find this in any php books)- if a now logged in user goes to the index page I want that user to see a logout rather than login button. Should I direct the member who logs in correctly to another index page (via a header )which is exactly the same except for the logout button in another file - maybe a secure file- or should I have them go to the same index page but write some php code in that index page that checks to see if a cookie has been set and prints a logout button if yes and a login button if no.

Following on- there are links on the index page that can only be followed if the user has logged on correctly. If I had two copies of the index page- one for users not logged on and one for logged on members, I would only have the links work for those logged on who are going from the logged in index page and direct the others going from the not logged inindex page to the log on page. Otherwise I would have to write code at the top of these members only pages to check to see if the user is logged on.

Configure Members.txt
I have download phpauth-v1. I manage to set up almost everything accept to login.
The read me file says: Create database text file on your webserver. e.g. members.txt
2. Edit phpAuth_config.php to suit your needs.

   2.1 Change the database name to the database text file you've created.   
   2.1 Edit the redirection for login and logout CHMOD your database text file to 666

I have done everything the demo members.txt file was given was like that:
admin   9003d1df22eb4d3820015070385194c8

Now in the login page I tried this combinatios but i got error login details. I changed to other username and password but the same result.

Members Only Downloads
Just wondering if anyone knows of a script that will perform (at least most of) the following tasks:

1. Hide the files actual location from the user (possibly not needed as I can store files outside of wwwroot).
2. Manage users who are allowed to download the file(s)
3. Will show all files in the folder for download without needing to set a link to each file manually

I can do the first two myself if there are no scripts readily available, however, the third, I'm not sure on.

Classes Can't Contain Object Members?
Using PHP 4.3.3; I'm trying to write a class that has as a member an
instance of another class. Assume class B is already written and supports
the method "method()".

class A {
var _desc;
var _obj;

function A() {
$this->_desc = "Desc test";
$this->_obj = new B();
$this->_obj->method(); // Works here
}

function helper() {
$this->_obj->method(); // Parse error claiming that I'm calling a
member function on a non-object
return;
}
}

Is this not possible in PHP? Is there another way?

Accesing To Members Of Objects
A short piece of code which i'm having problems with:

class ClsX{

var $F_name;
var $F_array_of_obj= array();

function ClsX(&$obj, $name){
//Here I add an object reference to an array. Note that all objects
inside $F_array_of_obj will be of X class or null values
$this->F_array_of_obj[] = $obj;
$this->F_name = $name;
$this->ListParents();
}

function ListParents(){
foreach ($this->F_array_of_obj as $obj) {
echo "Te name of the parent is: ". $obj->F_name;
}
}
}//class

$clsX1 = new ClsX("","name1");

$clsX2= new ClsX($clsX1, "name2");

I thought that this code would output

"the name of the parent is name1"

but it actually prints

""the name of the parent is"

Auto Email Greeting In PHP To Members
I am looking to build an PHP application which will automatically send
birthday greeting email to subscribers. The content of that email will
change from time to time. Please help. Links to tutorial to accomplish
this objective is very much appreciated.

Script That Emails A Newsletter To The Members
I am trying to write a script that emails a newsletter to the members in my database. I have it sending the email however it is not printing the name field in the email when sent. I even tried setting the name variable like so $name = $r1["name"]; Here is the code I am using: PHP Code:

Regular Emails To Database Members
I am building up a subscription database using authlib and mysql. I want to be able to send the subscribers a regular email, preferably calling the contents of the mail from a text file stored on the server.

User Area / Members Page
I have altered a simple member management system from a tutorial for my site. I have the login, logout, etc. all working fine. However I need to understand the concept behing having member pages.

Basically I'll have to type of users on my site, host and visitors/users. The host will have pages that they can maintain and broadcast and visitors can view the host pages based on whatever host they select. How do I go about making individual areas for each host upon their login? Sort of like a myspace system.

I am able to have a user control panel, see code below, but this is a page that only the host can see. I want a page that a host broadcast and vistors can view. Code:

Password Access Facility For 100s Of Members
What is the standard way (if there is one) to create a password facility where hundreds of people have a password, and can get a reminder by email?

I'm used to .htaccess but that is only good for a few passwords and doesn't let a visitors get a reminder by email.

I assumed this is a php question but I'm just as interested in another way. The site is on a unix/apache server with php and mysql.

Accessing Constant And Static Members Of A Class Name Held In A Variable
Does anyone please know of a way to access static methods of a class, when
the name of that class is held in a variable?

I have several classes (PHP5) which all have identically named methods and
members.

I want to pass the name of one of the classes to an included file which
does some standard operations using those methods and members. (So several
different programs can include that file, each passing a different class
name.)

I am doing this by putting the name of one of the classes in a variable
which is passed to the included file. So for example:
$classname = 'Foo'

$instance = new $classname();
$instance->do_method($id);

That all works fine.

But how do I access static methods and constant members of the class?

$classname::static_method()
and
$classname::MY_CONSTANT
both give errors. Every variation I've tried gives an error. Is there
something I'm missing in the syntax which will let me do this? Or maybe a
different method of passing the name, or of approaching the while thing?

I've found two ways of kludgeing round the problem. One is to use eval()
round everything, and the other (untested) is to use Reflection. But
surely there's a less messy way?


Help With Displaying Selecting A Date Range And Displaying Results
I wish to create a simple form that allows the selection of a start date and a stop date with the ability to select what columns to be displayed in the result page.

PHP Sessions - Who Is Logged In
I have a site that allows users to create multiple projects each with multiple sections. Each project builds a result based on the answers to a series of questions (different set for each section). As they answer, those answers are stored in a table. There can be multiple users per project.

I need it set up so that only one person can access a section of a project questions at once, so I created a "Lock" column in one of the database tables. Problem is that if a user is inactive, closes the browser, etc and their session is expired / removed from the list on the server, I need to remove the lock. Best idea I came up with is to store the Session ID in the Lock column and use a Cron job that checks the session ID's on the server. If no match is found, the Lock is removed. Problem is that I don't have a clue as to how to get a list of sessions from the server to see if they match any of the sessions stored in my Lock column.

Staying Logged In
How is that sites are able to use cookies somehow to log people in whenever they arrive. I can handle all the logging in part, and the session part, but I can't work out how to prevent people having to log in every time they are away long enough for the session to expire.

Logged In Twice At The Same Time?
Without going into the details of my code: is it possible to have two
different users logged in at the same time?

I had one page where I found the username correctly set, and another
where it wasn't. (Just by checking <?= $_SERVER['PHP_AUTH_USER'] >? at
the top of each page.)

Wondering why it would be set for one page and not another (and as a
sanity check) I wrote another page which sends the basic auth headers
and so logged in again.

Now the first page shows my original username. All the other pages
(which used to show username at all) now show the second username. I can
freely switch between them too: it's very consistent. One page, user1.
All the rest: user2.

I'm really confused. I didn't think it was possible to be logged in as
two different users in the same browser against the same host at the
same time.

How Can I Stay Logged In?
I've made a CPanel on my personal website so I can log in and edit my site from there. But now I've made it as simple as I stay logged in for 1 hour.. after that I get logged out automaticly..

so what I wonder is what can I do to stay logged in untill I either close the whole site or I'm idle for moer than 5 minutes?

Staying Logged In. . .
I have created a login script and it seems to work great - most of the time?? Sometimes (and I stress. . .sometimes), it logs the user out when they go from page to page. Here is the code I use to check it user is logged in: Code:

Nav If Member Logged In
i have a navigation script that pulls url's and name's out of a database.
However there are some links i only want people who are logged in to see..
I have made the login script and only this is needed in the if statment Code:

Determine How Long It Was Since Last Logged In?
I can insert the date and time into a SQL table, but where do I go from there? What would I use to figure out the exact minutes since they were last on?

Also, the minutes need to round to hours, and hours to days.

Check If A User Is Logged In
I'm trying to create a login app and I need to check if a user is logged in already or not and the send them to the aproriate page. Is this possible? If so, how do I do it?

Seeing Who Is Logged In From Encrypted Cookies
I am adding accounts to my site and have successfully implemented cookies, on log in the username and password (which first gets md5'd) entered are checked with the ones in the MySQL database. Then a cookie is set, one for the username, with the value of the md5(username) and the same for the password.

I can easily tell if someone is logged in to know what dynamic content to display, the problem is, I do not know the username, because it is encrypted.

Now I've got a few ideas on how to go about this, I could go through the Accounts table and md5 each of the usernames and check, but that would be inefficient. I've also thought about having another table with all the users who are logged in, that way I could also just set a single cookie.

Rather than fumbling around with this idea anymore I thought I'd get this right before I develop too much around it. What are some of the preferred methods around here?

How Can I Keep Data For Users That Are Not Logged In Yet
I am building a website and I want to allow users to do certain things
without logging in. I would like to allow them to keep track of certain
items, by adding them to a list.

Like if they are viewing multiple job listings in Houston, they can add each
job they care about to a list and when they are done looking at all the
jobs, they can view the list of say, 10 jobs. They can print the list or
email the list to themselves or someone else.

1st, what is the best way to track this user? IP address? I can have
multiple guest users online at any given time. I don't want to put them in
the database.

2nd, What is the best way to do this. Session variables? A session array?

What kind of data structure can I setup?

$visitorId = the ip address i get from $_SERVER['REMOTE_ADDR'] or should I
just use a session_id that php provides? Is that good enough?

$userLevel = "Guest"
$time = time();
$rememberItem = array();

Every time a visitor checks the remember me checkbox next to a job, I will
add that jobId to the $rememberItem session array.

Then when they want to see all of the jobs they asked to remember, I will
display a page that calls the database using each Id to display the title
and other info about each job. Then the user can print the page.

Effective 'Logged In' Checker?
I'm writing my own login script and have the following bit of code to check whether or not the users are logged or not. The script works, I'm just wondering if there are any security problems with it. Code:

Show Logged In User
I need a code that prints "Hello, $username" code can anybody help me by wrighting this out for me? I have the variable $username for the username.

Setting Logged In To A Variable
I am using this feature, so i can conditonally display stuff. Now, how do I set the result of the following to a variable so I can just use that, currently, I am doing it like the following:

 <?php
  if ((!isset($_SERVER['PHP_AUTH_USER'])) || ( !isset($_SERVER['PHP_AUTH_PW'])) ||($_SERVER['PHP_AUTH_USER'] != 'username) || ($_SERVER['PHP_AUTH_PW'] != 'passy' ));   
  else { 
?>   
SHOW RED
<?php
         }
?>

Verifying User Has Logged In.
Just starting to learn a bit about sessions and I am using the following bit of code to check that the user has logged in through the login page.

<?php
session_start ();
//this code checks to see if the user is logged in, if yes allowed to continue
//If not redirected to the login page
if (@$login |= "yes")
{
header ("location: login.php");
exit();
}
session_destroy();
?>

However the protected page can be still accessed from the Browser window by using the page URL bypassing login.

Show Logout Only If Logged In
I want to show a Logout link only if a user is actually logged in. Is there a way to show a bit of PHP code ONLY if a user session exists? If so, what's the code?

Proxy Users Getting Logged Out
I have a site that has always worked fine for most users but now i'm having problems with certain users getting logged out. I'm not certain, but in some cases at least they are behind a proxy.

My site uses phpBB's login code which performs a check against a portion of the user's ip address. I'm not sure if that's the issue...it could be something else relating to cookies and proxies. I know so little about proxies.

Anyway, the phpbb session-related code does the following:

1) gets user IP and encodes it thusly:

PHP Code: ....

List Contents Of A Folder, Make List Of Links
Does anyone know how I can write a script that:

- reads in all the files in a particular directory
- displays the file names in a html list and makes a link of them:
<ul>
<li><a href="filelocation1">filename 1</li>
<li><a href="filelocation2">filename 1</li>
<li><a href="filelocation3">filename 1</li>
</ul>

etc.?

So basically it creates a list of links with the contents in that directory,
so you can download them from there.

Get List Of Messages From One Table, Message List Indicator From
I have two tables. One has a list of messages left by users using fields named mbxno for the mailbox and msgno for the message number. I have another table that has mailbox settings for each user that contains a field named "messagelist" to indicate if they want to be included on the message list or not.

What I'm trying to create is a list of the most-recent messages with a lookup on the users table to indicate whether a message in the list should be included in the message list based on the user's mailbox settings.

SELECT messages.msgno, messages.mbxno, users.messagelist FROM messages, users WHERE (users.messagelist = &#391;') ORDER BY msgno DESC LIMIT 100

What I'm getting, though is a list that looks like this:

mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 1114 msgno: 0412141623 msglist: 1

I think what's happening is that I'm using the wrong type of join and more rows are being created than necessary.

If I add "DISTINCT" to the query, I get a list of the most-recent messages as I expect, but the "messsagelist" value is sometimes wrong (again, probably because the data is getting jumbled). For example, the messagelist value for the second row (2214) should be 0, not 1.

mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 2214 msgno: 0412141622 msglist: 1
mbxno: 2189 msgno: 0412141408 msglist: 1
mbxno: 0000 msgno: 0412141213 msglist: 1
mbxno: 0003 msgno: 0412141213 msglist: 1
mbxno: 2265 msgno: 0412132029 msglist: 1
mbxno: 0000 msgno: 0412131950 msglist: 1

How should I be doing this? If nothing else, what kind of join will work with a long list compared to a value from a short list?

How To Determine Logged In User In Oscommerce
Hi everyboy, I am working in oscommerce right now,Can anybody tell me how to
determine logged in user in oscommerce.I'll be very thankful if anybody assist
me.

How To Check If User Is Logged In In VBulletin With PHP
Anybody knows how to check if a visitor in vBulletin with a PHP script?

LDAP For Current Logged In User
We are trying to setup LDAP for users to utilize our Intranet and
perform some CMS stuff.. (we are using Active Directory). We are able
to bind and query, no problem.. We are using PHP on IIS and MySQL as
the DB

However I am wondering if there is a way to find out who is currently
logged in and even what their LDAP distinguishedName is.. For example
in VBScript I call objUser = GetObject("LDAP://" & strUserDN)....

If nothing is built in, is there a way to combine the vbscript and php
together and get it back?

If A User Visits The Website, The IP Is Logged
I want to write a script where if a user visits the website, the IP is logged. Now if the user visits the same page again, he is redirected to another page. This is specifically aimed at my static IP users.

Logged In Code Needing Re-adjusting?
I have a site developed where logged in users can earn virtual currency (echos) by doing certain actions. They can add items to their inventory, and sell these items to each other. I have the codes set up for all that (finally!). But all this has caused a problem to come to my attention.

If the logged in user is logged in, their echo count is displayed next to their username (for example: UsernameA Echos 100). If they leave a comment on a submitted image, they will get 10 echos and the number is updated (example: UsernameA Echos 110). If they buy an item from the shops, the number of echos gets deducted from their echo count successfully (example: UsernameA Echos 90).

So if all that is working, what`s the problem, right?

Well, if UsernameA gets any new private messages while they are logged in or if an item they sell to another person is bought, these things are not reflected. The person would have to log out, then log back in to see the "Messages (2 New)" and "Echos 100".

I`m thinking because these changes are not reflected, I might need my logged in codes re-done? Or maybe something else?

I need big time advice on what needs to be changed and how to do it. I`ll list some files that I think would be relevant:

index.php - the main page that user gets directed to when they log in
header.php - contains the info for design of the site and the navigation bar
logged.php - changes navigation bar to all info if perosn is logged in, if person is logged out, displayes login.php
login.php - form to allow person to log in
auth.php - loads session, reads from userdata for info of logged in person (such as username, how many echos they have, how many new messages they have)The posts below will show the codes for these files individually.

Member Logged In, Updating Their Details.
I have got a login system using sessions, and wanted to have a page where once the user is logged in, they can see and change/edit their details.

I have currently got two pages, modify_user.php and do_modify_user.php to try and do this, but i keep getting an error on do_modify_user.php that the query was empty. Code:

How To Allow Only Logged In Users To A Specific Webpage
I am wondering how I go about allowing those users who successfully login to be able to go to a certain page.  Those users who are not logged should be re-directed to login page.  I was able to get the user authentication to work fine on my site but not sure what I need to add to certain pages to check if a user is logged in.

How Can I Restrict Access To Files To Logged In Users Only?
I have a folder containing file1,file2,file3. I created a login system that sets the $_SESSION['id'] to a value if the user logged it. How can I restrict the access to my folder? I want the logged in users only to access it.

Logged In Users, Sessions And Flat File .txt
I am currently working on a project whereby users login to my website and then using a form add new quick links/tabs to their navigation bar. So for instance if the user had 'home/search engines/favourites' as links on their navigation bar and they wanted to add auction sites as a group link they fill out the form which then posts the data into a flat file database. (usertabs.txt)

So far i can make the form send the link name, URL and attach the username of the person adding links so to make a id for the link name and URL. So in the flat file the structure is presently: Code:

Unable To Show Current Logged In User
i am not sure what is going on but when i login and that works fine but if i want to show the the user who they are logged in as in the members section for example you are loged in as who ever, it does not show Code:


Copyright © 2005-08 www.BigResource.com, All rights reserved