Old 10-26-2005   1 links from elsewhere to this Post. Click to view. #1 (permalink)
code anyone?
 
scrowler's Avatar
 
Join Date: Feb 2004
Location: New Zealand
Posts: 590

Send a message via MSN to scrowler Send a message via Skype™ to scrowler
FAQ: A Complete Membership System

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.
Attached Files
File Type: zip addon_membercount.zip (445 Bytes, 122 views)
File Type: zip addon_memberlist.zip (533 Bytes, 130 views)
File Type: zip addon_source.zip (484 Bytes, 102 views)
File Type: zip addon_membersonline.zip (1.5 KB, 106 views)
File Type: zip addon_latestmember.zip (517 Bytes, 96 views)
__________________
BioRUST Tutorials - the birthplace

Last edited by scrowler; 11-20-2005 at 07:10 AM.
scrowler is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 10-27-2005   #2 (permalink)
Registered User
 
mmjosh1010's Avatar
 
Join Date: Oct 2005
Location: Devon, England
Posts: 26

Send a message via ICQ to mmjosh1010 Send a message via AIM to mmjosh1010 Send a message via MSN to mmjosh1010 Send a message via Yahoo to mmjosh1010
Thanks for these, I have used the member count addon and I have a problem. It keeps saying that there are 0 members, even though there are 5. Not sure if this is a problem with the script above or something I have done. Can anyone help?
mmjosh1010 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 10-30-2005   #3 (permalink)
code anyone?
 
scrowler's Avatar
 
Join Date: Feb 2004
Location: New Zealand
Posts: 590

Send a message via MSN to scrowler Send a message via Skype™ to scrowler
Josh, I have investigated this. I have installed a test script by downloading the source and following the tutorial, then cut and pasting the code exactly as one would who happened to find this tutorial and want to try it.

It works fine for me. If you cannot solve this problem, please create a thread in the Web Development Forum and one of our experienced members will help you debug your script.
__________________
BioRUST Tutorials - the birthplace
scrowler is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 10-31-2005   #4 (permalink)
Registered User
 
mmjosh1010's Avatar
 
Join Date: Oct 2005
Location: Devon, England
Posts: 26

Send a message via ICQ to mmjosh1010 Send a message via AIM to mmjosh1010 Send a message via MSN to mmjosh1010 Send a message via Yahoo to mmjosh1010
Scrowler - in the future will there be any other addons, for example a PM system for members.
__________________

Email - mmjosh1010@aol.com
mmjosh1010 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 11-01-2005   #5 (permalink)
code anyone?
 
scrowler's Avatar
 
Join Date: Feb 2004
Location: New Zealand
Posts: 590

Send a message via MSN to scrowler Send a message via Skype™ to scrowler
mmjosh1010 - possibly, but if so, they will be included in the tutorial rather than a straight download like the (basic) addons above. the purpose of addons on this script is just to enhance the workings, not to turn it into a fully fledged login system, as this is essentially not a "script" - rather a "tutorial". thanks for your interest.
__________________
BioRUST Tutorials - the birthplace
scrowler is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 01-05-2006   #6 (permalink)
Registered User
 
Join Date: Jan 2006
Posts: 4

Question hi.

I was wondering if it were possible to do this:

- okay, you have your index.php, with links to member only stuff, and if you try to access the page a message appears that says that you must login first.

- once you login at login.php, you are directed back to index.php, where the previously unaccessable links are now accessable

I know some PHP, but I'm not an expert, so you may need to explain things to me carefully. Thanks, guimonc001
guimonc001 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 01-19-2006   #7 (permalink)
code anyone?
 
scrowler's Avatar
 
Join Date: Feb 2004
Location: New Zealand
Posts: 590

Send a message via MSN to scrowler Send a message via Skype™ to scrowler
i think the first part of what you asked is already implemented in the tutorial, the second part is simply a matter of surrounding the element you wish to only appear if logged in with some php code:

Code:
<?php

if($_SESSION["s_username"]){

?>

<p>This will only appear if you are logged in!</p>

<?php } ?>
__________________
BioRUST Tutorials - the birthplace
scrowler is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 03-02-2006   #8 (permalink)
Ruffsta
Guest
 
Posts: n/a

duplicate emails...

i noticed you can't have the same username.. so why would someone be allowed to have the same email???

is there an updated register.php?

and i did everything right with mine(to my knowledege), however when i try to "activate" - i get:

"We are sorry, there appears to be an error processing your activation. Please try again later."

did i miss something?
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 03-06-2006   #9 (permalink)
code anyone?
 
scrowler's Avatar
 
Join Date: Feb 2004
Location: New Zealand
Posts: 590

Send a message via MSN to scrowler Send a message via Skype™ to scrowler
there is probably some settings that aren't enabled in your server configuration. try echo'ing mysql_error() after calling the query to see what's wrong.
__________________
BioRUST Tutorials - the birthplace
scrowler is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 07-13-2006   #10 (permalink)
BlacktTieDesigns.net
 
Join Date: Jun 2006
Location: United States
Posts: 3

Quote:
Originally Posted by scrowler
i think the first part of what you asked is already implemented in the tutorial, the second part is simply a matter of surrounding the element you wish to only appear if logged in with some php code:

Code:
<?php

if($_SESSION["s_username"]){

?>

<p>This will only appear if you are logged in!</p>

<?php } ?>
I tried this, but the only output I got was an epmty page.
http://blacktiedesigns.net/access/index.php
Just a testing page... I pasted the script you gave ^, and there still was an empty page on the output.
http://blacktiedesigns.net/access/accessindex.php (script I wanted shown):
This one includes a header.php/footer.php page to it. When I loaded it before there were continious output errors, like the one above

Code:
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/..../public_html/Untitled-2.php:7) in /home/..../public_html/access/login.php on line 2
the login page
Thank you for the help in advance.
BlackTie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 09-22-2006   #11 (permalink)
Registered User
 
Join Date: Sep 2006
Posts: 2

Scrowler - Is there an updated version that has all the addons and the fixed bugs fixed that have been found.. If so could you possibly give an updated .zip file or update the first one..

Is there away to make the menus.php to be horrizontal rather then vertically..

And is there away to add more links into it.. I have referred to the FAQ's and read the tutorials on every file thats been mentioned before the addons..

Also it would be nice to make this a fully functional membership program it would be very popular and might make a killing in funds for this site.. ^.^
DruidToolz is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 09-22-2006   #12 (permalink)
Registered User
 
Join Date: Sep 2006
Posts: 2

Ok srry for the double post..

But about the addons scowler.. When you say this..
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 );

?>
Do you mean to create another php file thats the same name and upload it to the main directory where the config, menus, etc php files are located at.. If this isn;t the case could you explain.. Thanks

Oh and about what i mentioned above about the links I found that collapsing menu answered that 2nd question above.. ^.^
DruidToolz is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 01-17-2007   #13 (permalink)
Registered User
 
Join Date: Jan 2007
Posts: 1

Cool About including...

First i wanna say what a great script U got there scrowler, nice job. My question is : how can i implement that login script with my index page?
Should i use something like <?php include.... ?> or what?
Please answer me, im really eager to know.

Thx

Delta
delta is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 01-18-2007   #14 (permalink)
Registered User
 
Join Date: Jan 2007
Posts: 2

Send a message via MSN to Tones
Ok the only issue i'm having with this now is the showing members online. the issue being if someone logs out, the name isn't removed from the list.

Even after waiting 5 or 6 minutes and refreshing the page. I see there is a timeout on the logging script set at 300 seconds. i'm assuming thats to check if the user is still on the site every 5 mins????

It's probably something i am doing wrong anyway, but any advise would be appreciated.

And Delta. what i did to implement the login was have the member.php script open up into an iframe on the site... if the person isnt logged in it shows the login form anyway. and created a link for member.php in my navigation.
Tones is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump