+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 12
Like Tree2Likes

Thread: phpBB3 external login

  1. #1
    caiol611 is offline x10Hosting Member caiol611 is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    7

    phpBB3 external login

    Hi,

    I am using phpBB3 and wanted to have an external login box from a page that is outside the forum directory. I have searched all over the phpBB3 support forums and haven't much information that was useful.

    So, what I would like to put on my site is a special login section with forms for username/password and a login button. After logging in, the code redirects to the forum index (/phpBB3/). If you return back to the personal website outside of the forum directory, and go back to the login area, only a logout button should appear. Clicking on the logout button goes to the forum page confirming logging out, then redirects to the home page of the personal website (outside of forum directory.

    I myself am a n00b when it comes to programming (i only have basic knowledge of html but a bit on how to edit css and php).

    The code that I found that works close to what I need is: http://area51.phpbb.com/phpBB/viewto...31eea&start=10

    PHP code goes in header
    Code:
    define('IN_PHPBB', true);
    define('PHPBB_ROOT_PATH', './phpBB3/');
    
    $phpbb_root_path = 'phpBB3/';
    
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);
    include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
    
    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    PHP forms (basically html)
    Code:
    /* Start Logout*/
                         if ($user->data['is_registered']){
                         echo("<form method='post' action='".$phpbb_root_path."ucp.php?mode=logout&amp;sid=".$user->data['session_id']."'>");
                         echo("<input type='submit' name='logout' value='Logout'>");
              echo("<input type='hidden' name='redirect' value='../index.php'>"); 
                         echo("<br /></form>");
                         }
                        /*End Logout*/
    
                         /*Start Login Box*/
                         if (!$user->data['is_registered']){
                                    echo("form method='post' action='".$phpbb_root_path."ucp.php?mode=login'>");
                                    echo(" Username:");
    The above code works for me, its only that I cant get the login/logout redirects to the pages that I want. Anyone with any phpBB3 modding experience? Any help is much appreciated.

    Thanks
    Last edited by caiol611; 04-11-2008 at 03:47 PM.
    dinomirt96 likes this.

  2. #2
    caiol611 is offline x10Hosting Member caiol611 is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    7

    Re: phpBB3 external login

    I got my problem solved ;)

    So, on the top of my login.php file, which is outside of the forum directory (phpBB3/) and on my normal website, I put the following code:

    Code:
    <?php
    define('IN_PHPBB', true);
    define('PHPBB_ROOT_PATH', './phpBB3/');
    
    $phpbb_root_path = 'phpBB3/';
    
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);
    include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
    
    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    
    if($user->data['is_registered']){
    redirect("$phpbb_root_path");
    break;
    }
    ?>
    I was basically missing the:

    Code:
     if($user->data['is_registered']){
    redirect("$phpbb_root_path");
    break;
    which signifies if the user is registered, then clicking on the forum button links directly to the forum index, bypassing the login page.

    On the same login.php in the body, I put the following code:

    Code:
    <h2>Login Panel</h2>
    <?php
    
    /*Start Logout*/
    if ($user->data['is_registered']){
    echo("<form method='post' action='".$phpbb_root_path."ucp.php?mode=logout&amp;sid=".$user->data['session_id']."'>");
    echo("<input type='submit' name='logout' value='Logout'>");
    echo("<br /></form>");
    }
    /*End Logout*/
    
    /*Start Login Box*/
    if (!$user->data['is_registered']){
    echo("<form method='post' action='".$phpbb_root_path."ucp.php?mode=login'>");
    echo(" Username:");
    echo(" <input type='text' name='username' size='15' value=''>");
    echo("<br /><br />");
    echo(" Password:");
    echo(" <input type='password' name='password' size='15' value=''>");
    echo("<br /><br />");
    echo("<input type='submit' name='login' value='Login'>");
    echo("<br /></form>");
    echo("<br />");
    echo("Don't have an account? Please register <a href='phpBB3/ucp.php?mode=register'>here</a>.");
    }
    /*End Login Box*/
    ?>
    This contains all the forms for the username/password plus a register link on the bottom.

    Most of the code has been copied from codes already posted in the phpBB3 Support Forum. I hope that whoever plans to implement an external login panel in their website will find this useful.


    Edit:
    I also forgot an important piece that I forgot to mention....:happysad:

    On line 95 in the ucp.php file under your phpBB3 directory, replace

    Code:
    meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx")));
    with

    Code:
    ## LOGOUT REDIRECT HACK  -- BEGIN ##
    $redirect = request_var('redirect', "../index.html");
    meta_refresh(3, append_sid($redirect));
    ## LOGOUT REDIRECT HACK  -- END ##
    Logging out of the forum redirects the user back to the homepage (or replace ../index.html with whatever page you want).

    Hope this helps.
    Last edited by caiol611; 04-13-2008 at 10:44 AM. Reason: Automerged Doublepost
    karimirt47 likes this.

  3. #3
    Jose Magsino is offline x10Hosting Member Jose Magsino is an unknown quantity at this point
    Join Date
    Jan 2008
    Posts
    53

    Re: phpBB3 external login

    Cool!


    Thanks for sharing your experience.

  4. #4
    DeadBattery's Avatar
    DeadBattery is offline Community Support Team DeadBattery is a name known to allDeadBattery is a name known to all
    Join Date
    Mar 2008
    Location
    localhost
    Posts
    4,019

    Re: phpBB3 external login

    Thanks, I'll bookmark this and if I need it, I'll give you some rep.


  5. #5
    nutan.lade is offline x10Hosting Member nutan.lade is an unknown quantity at this point
    Join Date
    Apr 2008
    Posts
    2

    Re: phpBB3 external login

    Hey I tried the above code but it is giving that config.php is not found and a link to install phpbb3.How to solve this one.Reply immediately please.

  6. #6
    caiol611 is offline x10Hosting Member caiol611 is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    7

    Re: phpBB3 external login

    As I am not a PHP expert nor do I know much about programming, all I can say is that you should play around with the $phpbb_root_path setting and/or other areas that refer to a page. I have no idea how your site is structured so I guess it is simply adjusting the code to fit your site.

  7. #7
    wolf693's Avatar
    wolf693 is offline x10 Sophmore wolf693 is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Newberg, OR -er, SOMEWHERE!!!
    Posts
    112

    Re: phpBB3 external login

    This is a good idea! I've seen it on a couple websites and never really had an idea on how it worked.

  8. #8
    TechAsh's Avatar
    TechAsh is offline Retired TechAsh is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    UK
    Posts
    5,853

    Re: phpBB3 external login

    Thanks.
    I've been looking for a way to do this for ages. I'll bookmark this page and give it a go when I have some spare time.
    Useful Links:
    Terms of Service | Server News | Buy a Domain
    Free Domains: co.cc | Dot.tk -- Free File Storage: Dropbox -- Website Monitoring: Service Uptime


    My Websites:
    Earthtime Games & TechAsh's Blog

  9. #9
    nutan.lade is offline x10Hosting Member nutan.lade is an unknown quantity at this point
    Join Date
    Apr 2008
    Posts
    2

    Re: phpBB3 external login

    In the root of the web directory i have some web pages through which i need a xtrnal login.I already installed phpbb3 forums and it is located in forums directory.But while using the above script and I tried to login but it was saying that

    The requested URL /'.$phpbb_root_path.'/ucp.php was not found on this server.

    And the code i used in the webpage is

    define('IN_PHPBB', true);
    define('PHPBB_ROOT_PATH', './forums/');

    $phpbb_root_path = 'forums/';

    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);
    include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

    // Start session management
    $user->session_begin();
    $auth->acl($user->data);


    Please solve the problem as soon as possible.

    Thanq in advance....

  10. #10
    caiol611 is offline x10Hosting Member caiol611 is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    7

    Re: phpBB3 external login

    So, your forum is placed inside a folder called "forums" which is inside the public_html folder, correct? If your login PHP page is located right under public_html but outside of your forum directory, you should have no problems. It looks to me that your code is correct. I dunno...:dunno:
    Last edited by caiol611; 04-26-2008 at 02:27 PM.

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Cant login to Cpanel/FTP
    By RonSijm in forum Free Hosting
    Replies: 3
    Last Post: 03-10-2008, 01:41 AM
  2. Can not login to cpanel
    By insane85 in forum Free Hosting
    Replies: 28
    Last Post: 02-26-2008, 11:31 PM
  3. Unable to login properly,
    By icefire in forum Free Hosting
    Replies: 3
    Last Post: 02-06-2008, 10:17 PM
  4. The previous way of login?
    By halchalgroups in forum Free Hosting
    Replies: 1
    Last Post: 09-22-2007, 02:07 AM
  5. A simple Visual Basic Login Form
    By Zenax in forum Tutorials
    Replies: 0
    Last Post: 03-13-2007, 08:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers