Results 1 to 16 of 16
  1. #1
    Join Date
    Jan 2002
    Location
    Toronto, Canada
    Posts
    11,059

    phpBB login question

    In a phpBB forum, I want to give members access to the information in a database. This database is part of a PHP script, but the problem is that the script requires that users login to access it. Well, I don't want forum users to have to login twice.

    Is there any way to tie the 2 logins together so that when members login, they are automatically logged in to both?

    Vito
    DemoDemo.com - Flash tutorials since 2002
    DemoWolf.com - 5,300+ Flash tutorials for hosting companies, incl. Voice tutorials

  2. #2
    Join Date
    Oct 2003
    Posts
    115
    I am not sure if I understand correctly
    you have phpBB and another script? each with it's own database correct? if you don't want to edit the phpbb code to integrate the other script into it, you can simple just find the login function of the other script and call it when the user logs in to phpbb and have it switch databases when it wants to pull data from the other db.

    or even easier (and dirtier ) approach, have the other script use the same database phpbb uses, then no switching required

    but either way, you will need to edit some code.

  3. #3
    Join Date
    Jan 2002
    Location
    Toronto, Canada
    Posts
    11,059
    Thanks for the reply. I sort of understand what you're saying but not entirely. Let me be more specific about what I'm trying to do.

    It's a cooking forum using phpBB. I also just bought a "recipe" script that allows people to upload recipes to the MySQL database. And in order to upload a recipe, you have to login first.

    So what I want to do is have a link in the forum taking the member to the recipe script pages. But I want to avoid the need for the member to have to login to the recipe area. In other words, when logging into the forum, I want that to log the member into both forum and recipe script.

    Vito
    DemoDemo.com - Flash tutorials since 2002
    DemoWolf.com - 5,300+ Flash tutorials for hosting companies, incl. Voice tutorials

  4. #4
    Join Date
    Dec 2002
    Location
    NY, NY
    Posts
    3,975
    Vito, i assume you are using PHP
    well, since your recipe script has nothing to do with the forum [physically], you would have to change the code for that.
    Look in the phpBB files to see how they check for log-in.
    Then copy that and replace it with the script that checks for log-in for the recipe script.
    I guess the recipe script uses a database.
    So instead of it going to its own DB, make it go to the phpBB user db.

  5. #5
    Join Date
    Mar 2003
    Posts
    878

    Re: phpBB login question

    Originally posted by vito
    In a phpBB forum, I want to give members access to the information in a database. This database is part of a PHP script, but the problem is that the script requires that users login to access it. Well, I don't want forum users to have to login twice.

    Is there any way to tie the 2 logins together so that when members login, they are automatically logged in to both?

    Vito
    My phpBB version(2.0.5 or earlier) is rather old, I am NOT sure if any changes in the newer version.

    This is what i did
    PHP Code:
    <?php
    define
    ('IN_PHPBB'true); 
    $phpbb_root_path 'forum/'
    include(
    $phpbb_root_path 'extension.inc'); 
    include(
    $phpbb_root_path 'common.'.$phpEx); 

    $userdata session_pagestart($user_ipPAGE_INDEX);
    init_userprefs($userdata);


    if (
    $userdata['session_logged_in']){ 
      
    //User logged-in Block
      //$userdata["username"] is the username from phpBB
    }
    else 
      
    //NON registered user Block     
    ?>
    Hope I got it right

  6. #6
    Join Date
    Jan 2002
    Location
    Toronto, Canada
    Posts
    11,059
    Thanks, silhouette. I'm just not sure what to do with that code, though.

    Do I add it to one of my files?

    Vito
    DemoDemo.com - Flash tutorials since 2002
    DemoWolf.com - 5,300+ Flash tutorials for hosting companies, incl. Voice tutorials

  7. #7
    Join Date
    Mar 2003
    Posts
    878
    Originally posted by vito
    Thanks, silhouette. I'm just not sure what to do with that code, though.

    Do I add it to one of my files?

    Vito
    Oh sorry!! I overlooked some clarifying points....


    Basically(from what I understand)...the following chunk:
    PHP Code:
    define('IN_PHPBB'true); 
    $phpbb_root_path 'forum/'
    include(
    $phpbb_root_path 'extension.inc'); 
    include(
    $phpbb_root_path 'common.'.$phpEx); 

    $userdata session_pagestart($user_ipPAGE_INDEX); 
    init_userprefs($userdata); 
    is borrowed from phpBB codes exactly.

    IMPORTANT::
    **before u can use that chunk, make sure u have setup your phpBB in a dir "forum", and your sql running.
    **I took the advantage of my phpBB forum entirely.This way of implementing is very primitive(I did it quite some times back), which my site only allows members to register in my phpBB forum NOT from my main page!!

    I put that chunk at the begining of my own page in order to have status of the data like:
    $userdata['session_logged_in']...to know whether the user is loggin
    $userdata["username"] ...to get the user's userid
    etc,(u may check the source of phpBB for more variable that is useful to your script.)

    FOR my case,
    I want to get my forum's member username onto main main page.(i actually use the cookie and session implemented by my phpBB forum), so my code will go something like:
    PHP Code:
    <?php 
    session_start
    ();

    define('IN_PHPBB'true); 
    $phpbb_root_path 'forum/'
    include(
    $phpbb_root_path 'extension.inc'); 
    include(
    $phpbb_root_path 'common.'.$phpEx); 

    $userdata session_pagestart($user_ipPAGE_INDEX);
    init_userprefs($userdata);

    if (
    $userdata['session_logged_in']){ 
      
    $myUsername=$userdata["username"];//I got my own username here
      
    $_SESSION['myMainSession']=TRUE;//my own session    
    }
    else 
         
    $myUsername="Unregistered";

    if(
    $_SESSION['myMainSession']){
    // member area

    }
    ?>

  8. #8
    Join Date
    Jan 2002
    Location
    Toronto, Canada
    Posts
    11,059
    Hey, ilyash, I didn't see your post. Thanks for the input.

    Silhouette, When I receive delivery of the recipe script on Monday, I will try to follow your directions and see how it turns out. Thanks.

    Vito
    DemoDemo.com - Flash tutorials since 2002
    DemoWolf.com - 5,300+ Flash tutorials for hosting companies, incl. Voice tutorials

  9. #9
    Join Date
    Jan 2002
    Location
    Toronto, Canada
    Posts
    11,059
    OK, here's an update to the issue. I decided to email the script developer to see if he had any thoughts on it. Apparently, I was mistaken. The recipe script does not require a login. But this is what he suggested:

    Actually you do not have to login to use the script. I'm not a big believer in forcing logins. However, what I would do is take the code from your forum that passes the login data and make small header file with it to put at the top of each cookbook page using php's include function.
    So what phpBB code is he referring to? (I'm sadly lacking in programming skills, as you can tell).

    Vito
    DemoDemo.com - Flash tutorials since 2002
    DemoWolf.com - 5,300+ Flash tutorials for hosting companies, incl. Voice tutorials

  10. #10
    Join Date
    Mar 2003
    Posts
    878
    Originally posted by vito
    ...So what phpBB code is he referring to?......Vito
    I read hard to understand what he really mean....

    Is he saying he need just the header portion of your phpBB forum like this(see attached)
    Attached Thumbnails Attached Thumbnails wht.gif  

  11. #11
    Join Date
    Jan 2002
    Location
    Toronto, Canada
    Posts
    11,059
    No, I don't think he means a "graphical" header file. I think he means to just put an include (which addresses whether the member has logged into the forum or not) into the top of all recipe script pages.

    Vito
    DemoDemo.com - Flash tutorials since 2002
    DemoWolf.com - 5,300+ Flash tutorials for hosting companies, incl. Voice tutorials

  12. #12
    Join Date
    Mar 2003
    Posts
    878
    Originally posted by vito
    No, I don't think he means a "graphical" header file. I think he means to just put an include (which addresses whether the member has logged into the forum or not) into the top of all recipe script pages.

    Vito
    OK if that is the case, then I think the code that I provided fits the bill well!! In fact I am using something like that in my "late" forum.

    NOTE:: The code works BUT there may be more efficient way of doing it. Maybe phpBB experts here can shed a light.

    PHP Code:
    <?php
    //include at the begining of your page and make sure your phpBB installed and sql running

    define('IN_PHPBB'true); 
    $phpbb_root_path 'forum/'// set to '/' if the script is in the same level
    include($phpbb_root_path 'extension.inc'); 
    include(
    $phpbb_root_path 'common.'.$phpEx); 

    $userdata session_pagestart($user_ipPAGE_INDEX); 
    init_userprefs($userdata); 
    /* your code goes here where
    *$userdata['session_logged_in'] is true if user logged-in, else false
    *$userdata["username"] is his username 
     */ 
    ?>
    Hope my memory serve me right. Any expert running phpBB now can share??!!

  13. #13
    Join Date
    Jan 2002
    Location
    Toronto, Canada
    Posts
    11,059
    Hmm. OK, that seems simple enough.

    1. Just to clarify, you're saying that if I add this code to all the php pages in the recipe script, a visitor is not able to view the recipe pages unless logged into the forum?

    2. The "recipe" folder is in the "forum" folder. ( www.site.com/forum/recipe/ ). So what should the $phpbb_root_path be?

    3. Aside from #2 setting above, should I be configuring anything else?

    Thanks so much for your help, silhouette.

    Vito
    DemoDemo.com - Flash tutorials since 2002
    DemoWolf.com - 5,300+ Flash tutorials for hosting companies, incl. Voice tutorials

  14. #14
    Join Date
    Mar 2003
    Posts
    878
    Originally posted by vito
    1. Just to clarify, you're saying that if I add this code to all the php pages in the recipe script, a visitor is not able to view the recipe pages unless logged into the forum?

    2. The "recipe" folder is in the "forum" folder. ( www.site.com/forum/recipe/ ). So what should the $phpbb_root_path be?

    3. Aside from #2 setting above, should I be configuring anything else?
    1. NOT exactly, BUT very near. I added just a little more to suit your need. see below with explanation

    2.use this instead:
    PHP Code:
    '../' 
    3.Nothing(IF your forum is running fine!!)
    PHP Code:
    <?php 
    //include at the begining of your page and make sure your phpBB installed and sql running 

    define('IN_PHPBB'true); 
    $phpbb_root_path '../'// set to '/' if the script is in the same level 
    include($phpbb_root_path 'extension.inc'); 
    include(
    $phpbb_root_path 'common.'.$phpEx); 

    $userdata session_pagestart($user_ipPAGE_INDEX); 
    init_userprefs($userdata);
    if (
    $userdata['session_logged_in']){ 

    //MEMBER AREA
    //your receipe code goes here where 
    // $userdata["username"] is his username 

    }
    else{

    //NON-Member area 

    }

    ?>
    AGAIN NOTE:: I did this based on my memory, U have to test out and code!!!!

  15. #15
    Join Date
    Jan 2002
    Location
    Toronto, Canada
    Posts
    11,059
    Very cool. I'll try it tomorrow morning.

    Thanks, silhouette!!

    Vito
    DemoDemo.com - Flash tutorials since 2002
    DemoWolf.com - 5,300+ Flash tutorials for hosting companies, incl. Voice tutorials

  16. #16
    Join Date
    Mar 2003
    Posts
    878
    I think is best to ask your programmer to check out
    phpBB forum and search with search string "login redirect" or something like that.
    You will have better/more professional answer there

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •