SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict tempyyyst's Avatar
    Join Date
    Nov 2001
    Location
    Kent, UK
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using phpBB authentication on other pages

    Hi all

    I want to use phpBB's authentication to restrict access to a 'user reviews' section on my DVDRecorderWorld site (see sig).

    I'm following this tutorial.

    Which basically involves sticking code a bit like this into the page:

    PHP Code:
      define('IN_PHPBB'true);
        
    $phpbb_root_path './forum/';
        include(
    $phpbb_root_path 'extension.inc');
        include(
    $phpbb_root_path 'common.'.$phpEx);
        
        
    //
        // Start session management
        //
        
    $userdata session_pagestart($user_ipPAGE_INDEX);
        
    init_userprefs($userdata);
        
    //
        // End session management
        //
        
        // phpBB session test
        
        
    if( $userdata['session_logged_in'] )
           {
              echo(
    'logged in');
           }
        else
               {
                       echo(
    'Please Login');
               } 
    but if you take a look at

    http://www.dvdrecorderworld.com/reviewtest.php?model=60

    you'll see an error message (which annoyingly I can't reproduce once I logged in) involving headers.

    Anyone got any tips as you what this means and where I should be looking to fix it?

    Jay

  2. #2
    PHP Otaku Gibb's Avatar
    Join Date
    Jul 2004
    Location
    Texas
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that error means you've done something that outputs data before using the header function (for redirecting or what not). You cant have outputted data on the same page as a header redirect.

  3. #3
    SitePoint Addict tempyyyst's Avatar
    Join Date
    Nov 2001
    Location
    Kent, UK
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. So, the headers are first being sent by my parent php page and then something in phpBB is trying to resend.

    Any phpBB experts out there come across this before?

  4. #4
    SitePoint Addict tempyyyst's Avatar
    Join Date
    Nov 2001
    Location
    Kent, UK
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, solved the headers problem by moving the phpBB include stuff right to the top of the page, but now I'm getting other SQL errors.

    Looks as though having the phpBB session stuff at the top of the page is stopping the passing of the variable $model.

    Anyone know why?

    PHP Code:
    <?php
       
       define
    ('IN_PHPBB'true);
       
    $phpbb_root_path './forum/';
       include(
    $phpbb_root_path 'extension.inc');
       include(
    $phpbb_root_path 'common.'.$phpEx);
       
       
    //
       // Start session management
       //
       
    $userdata session_pagestart($user_ipPAGE_INDEX);
       
    init_userprefs($userdata);
       
    //
       // End session management
       //
       
       
    include("<include path>/db_connect.php");
       
       echo (
    "<p>Modelid: $model</p>");
       
     
    $modelsql "SELECT model, manu, amazon_asinuk, amazon_asinus FROM model LEFT JOIN manu ON manu_id=manu.id WHERE model.id=$model";
       
       
    $modelfields = @mysql_query("$modelsql");
       if (!
    $modelfields) {
           echo(
    "<p>ERROR2:" mysql_error() ."\n SQL: $modelsql</p>" );
           exit ();
       }
    gives me

    Code:
     Modelid: 
    
     ERROR2:You have an error in your SQL syntax near '' at line 1  SQL: SELECT model, manu, amazon_asinuk, amazon_asinus FROM model LEFT JOIN manu ON manu_id=manu.id WHERE model.id=

  5. #5
    PHP Otaku Gibb's Avatar
    Join Date
    Jul 2004
    Location
    Texas
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    where were you getting the $model variable from? was it stored in a $_SESSION, or from $_GET?

    If you have some code for retrieving $model down below, you'll need to move that up as well.

  6. #6
    SitePoint Addict loadx's Avatar
    Join Date
    Jul 2004
    Location
    Melbourne, VIC, Australia
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    could be in a different include ?

  7. #7
    SitePoint Addict tempyyyst's Avatar
    Join Date
    Nov 2001
    Location
    Kent, UK
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  8. #8
    PHP Otaku Gibb's Avatar
    Join Date
    Jul 2004
    Location
    Texas
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    then move the code that grabs the $_GET variable to the top of the page, before the phpBB code (so long as there's no echo statements or such that would cause a header error again).

  9. #9
    SitePoint Addict tempyyyst's Avatar
    Join Date
    Nov 2001
    Location
    Kent, UK
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, that's done it.


Bookmarks

Posting Permissions

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