after having many questions about the complete membership system tutorial, i have decided to create an FAQ thread for them. if your question is not answered here, please ask me via PM, thread in the
web development forum, or by email and it may be added to this thread.
Q: I get an error: session_start(): Cannot send session cookie - headers already sent by (output started at [file.php]:1) in [file.php] on line 2
Problem: session_start() must be called before
any output it sent to the browser. This includes spaces outside PHP tags and HTML.
Solution: Make sure you have no spaces or HTML code before the line that calls session_start(). Whitespace counts as output to the browser.
This tutorial was aimed at reasonably experienced developers. If you cannot figure this out or did not know this, or are just cut and pasting the tutorial code rather than learning from it as intended, then this tutorial is probably not for you.
Q: How can I create a member list for my membership script?
A: I have had a few requests for how to do this. There is now an addon available that will do this. The member list addon script is in a zip file attached to this thread called "addon_memberlist.zip". To install:
1) Unzip, and upload the file "memberlist.php" to a new folder called "addons" in your membership system directory.
2) To use it, you can create a page like this:
PHP Code:
<?php
# get the function
include "addons/memberlist.php";
# show only activated members? 1 = yes, 0 = no
$activated_only = 0;
# order by column name (default Username)
$order_by = "Username";
# order (default ASC). either ASC or DESC
$order = "ASC";
# show member list
showMemberList( $activated_only, $order_by, $order );
?>
To modify the HTML output for the memberlist loop, modify the "memberlist.php" file in the addons directory.
Q: How can I create a member counter for my membership script?
A: I have had a few requests for how to do this. There is now an addon available that will do this. The member counter addon script is in a zip file attached to this thread called "addon_membercount.zip". To install:
1) Unzip, and upload the file "membercount.php" to a new folder called "addons" in your membership system directory.
2) To use it, you can create a page like this:
PHP Code:
<?php
# get the function
include "addons/membercount.php";
# show only activated members? 1 = yes, 0 = no
$activated_only = 0;
# show member counter
echo "There are: " . showMemberCount( $activated_only ) . " members.";
?>
To modify the HTML output for the memberlist loop, modify the "membercount.php" file in the addons directory.
Q: How do I display the user's username/name in my script?
A: The username is stored in a session superglobal variable called:
$_SESSION["s_username"];
And the name is stored in:
$_SESSION["s_name"];
Q: I downloaded your example code, and it keeps giving me an error looking for menus.php
Problem: menus.php was only included as a demonstration, integrating a different tutorial.
Solution: Create your own menus, or download the latest source code as menus.php is included in it.
Q: I downloaded your source code and when I run it is gives me an error looking for 'config.php'
Problem: config.php is not included in the source code.
Solution: This is intended as a tutorial, not a free script. There is a certain amount of user input involved in getting this to work. You must follow the tutorial and use the information on the first page for how to set up config.php.
Q: Is there an online demonstration I can see of this tutorial working with all the mods?
A: Yes.
Click here. This version has been slightly modified implementing better coding structures in various places for increased speed and stability. There is a source code viewing function in place with links to view the source of each page on most pages. This is not included in the tutorial, but if you are interested in finding out how to do this, you can download the addon for source code attached at the bottom of this post, and use this code to implement it:
PHP Code:
<?php include "addons/source.php" ?>
Do not use this on any pages that have a header() redirect or session_start() call, or any similar function that requires no browser output prior to calling, as it will trigger an error which will most likely stop your script working.
Q: How can I create an addon to show the latest registered member?
A: There is now an addon available that will do this. The latest member addon script is in a zip file attached to this thread called "addon_latestmember.zip". To install:
1) Unzip, and upload the file "latestmember.php" to a new folder called "addons" in your membership system directory.
2) To use it, you can create a page like this:
PHP Code:
<?php
# get the function
include "addons/latestmember.php";
# show only activated members? 1 = yes, 0 = no
$activated_only = 0;
# show latest member
showLatestMember( $activated_only );
?>
To modify the HTML output for the memberlist loop, modify the "latestmember.php" file in the addons directory.
Q: How can I create a list of members online/counter for members online?
A: There is now an addon available that will do this. The latest member addon script is in a zip file attached to this thread called "addon_membersonline.zip". To install:
1) Unzip, and upload the files to a new folder called "addons" in your membership system directory.
2) Run the "membersonline_dbsetup.php" file, and if it says "Done!" then relax for not having to debug it.
3) To log each user being logged in, add this into "member.php"
after "include 'process.php';" line:
PHP Code:
# log the user being logged in:
include 'addons/membersonline_logusers.php';
# done, continue
4) To use it, you can create a page like this:
PHP Code:
<?php
# get the function
include "addons/membersonline.php";
# show only activated members? 1 = yes, 0 = no
$activated_only = 0;
# show a number of online users instead of a list of usernames? 1 = yes, 0 = no
$number = 0;
# get the data
$users = showMembersOnline( $activated_only, $number );
if($number) echo "<p>There are {$users} user(s) logged in.</p>";
else {
echo "<p>Users currently logged in: ";
foreach($users as $current){
if($count) echo ", ";
echo $current;
$count++;
}
echo "</p>";
}
echo "<p>Based on statistics from the last " . $timeout / 60 . " minutes.</p>";
?>
To modify the HTML output for the memberlist loop, modify the code above.