Jump to content

Help with Webpage phpBB login integration.


Dyno

Recommended Posts

On my website i have a login username/password box i have it when you enter your login details it'll log you into the forums.

 

When no ones loged in theres no problems but when someone logs in i get the error on my index page

 

Warning: Cannot modify header information - headers already sent by (output started at /home/adaminc/public_html/index-test.php:5) in /home/adaminc/public_html/forums/includes/sessions.php on line 254

 

Warning: Cannot modify header information - headers already sent by (output started at /home/adaminc/public_html/index-test.php:5) in /home/adaminc/public_html/forums/includes/sessions.php on line 255

 

On my sessions.php file those 2 lines are

Line 254

setcookie($cookiename . '_sid', $session_id, 0, $cookiepath, $cookiedomain, $cookiesecure);

Line 255 is blank

 

On my index-test.php file the php code is

<?php
define('IN_PHPBB', true);
$phpbb_root_path = 'forums/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length);
init_userprefs($userdata);
if(!$userdata['session_logged_in']) {
echo ' ';
?>
<form method="post" action="forums/login.php">
<font size="2" face="Verdana, Arial, Helvetica, sans-serif">Username: <input class="post" type="text" name="username" size="12" style="font-family: Arial; font-size: 10px; border: 1px solid #808080"/><br>
<font size="2" face="Verdana, Arial, Helvetica, sans-serif">Password: <input class="post" type="password" name="password" size="7" style="font-family: Arial, font-size: 10px; border: 1px solid #808080"/>
<br>Remember Me: <input class="text" type="checkbox" name="autologin" />
<input type="submit" class="mainoption" name="login" value="Log in" style="border: 1px solid #333333; font-family:Arial; font-size:10px; color:#000000; text-transform:uppercase; background-color:#E9E9E9" />
<br>
<font size="1" face="verdana, Arial, Helvetica, sans-serif">
<img src="forums/templates/DustyGreen/images/icon_mini_search.gif" border="0" align="middle"> <a href="forums/search.php">Search</a>
 
<img src="forums/templates/DustyGreen/images/icon_mini_register.gif" border="0" align="middle"> <a href="forums/profile.php?mode=register">Register</a></font>
   </form>


<?php
}
else {
echo '<font size="2" face="Arial, verdana, Helvetica, sans-serif">Hi, '.$userdata['username'] ;
echo '</font><br><font size="1" face="Arial, verdana, Helvetica, sans-serif">';
echo '<img src="forums/images/folder.gif" border="0" align="middle"> <a href="'.append_sid("forums/privmsg.php?folder=inbox").'" title="Private Messages">Inbox</a> ['.$userdata['user_new_privmsg'].']';
echo ' <img src="forums/images/icon_mini_profile.gif" border="0" align="middle"> <a href="'.append_sid("forums/profile.php?mode=editprofile").'" title="Edit profile">Profile</a><br>';
echo '<img src="forums/images/icon_mini_search.gif" border="0" align="middle"> <a href="'.append_sid('forums/search.php').'">'.$lang['Search'].'</a>';
echo ' <img src="forums/images/icon_mini_search_new.gif" border="0" align="middle">  <a href="'.append_sid('forums/search.php?search_id=newposts').'">'.$lang['Last_Post'].'</a><br>';
echo '<img src="forums/images/icon_mini_login.gif" border="0" align="middle"> <a href="'.append_sid('forums/login.'.$phpEx.'?logout=true&sid=' . $userdata['session_id']).'">Logout</a> </font><br>';


}

?>

 

I"m not sure why i'm getting that error if someone can help me fix it i'd be happy thanks.

Link to comment
Share on other sites

Thanks for that it worked great.  The only thing i cant get working is the cookie that keeps me logged in.

 

<?



class PHPBB_Login {



    function PHPBB_Login() {

    }



    function login( $phpbb_user_id ) {

        global $db, $board_config;

        global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;

    

        // Setup the phpbb environment and then

        // run through the phpbb login process



        // You may need to change the following line to reflect

        // your phpBB installation.

        require_once( './forums/config.php' );

    

        define('IN_PHPBB',true);



        // You may need to change the following line to reflect

        // your phpBB installation.

        $phpbb_root_path = "./forums/";

        

        require_once( $phpbb_root_path . "extension.inc" );

        require_once( $phpbb_root_path . "common.php" );



        return session_begin( $phpbb_user_id, $user_ip, PAGE_INDEX, FALSE, TRUE );

    

    }



    function logout( $session_id, $phpbb_user_id ) {

        global $db, $lang, $board_config;

        global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;

    

        // Setup the phpbb environment and then

        // run through the phpbb login process



        // You may need to change the following line to reflect

        // your phpBB installation.

        require_once( './forums/config.php' );

    

        define('IN_PHPBB',true);

        

        // You may need to change the following line to reflect

        // your phpBB installation.

        $phpbb_root_path = "./forums/";



        require_once( $phpbb_root_path . "extension.inc" );

        require_once( $phpbb_root_path . "common.php" );



        session_end( $session_id, $phpbb_user_id );

    

        // session_end doesn't seem to get rid of these cookies,

        // so we'll do it here just in to make certain.

        setcookie( $board_config[ "phpbb2mysql" ] . "_sid", "", time() - 3600, " " );

        setcookie( $board_config[ "phpbb2mysql" ] . "_mysql", "", time() - 3600, " " );



    }



}



?>

 

thats the code used can anyone see where its not working.  the cookie name on the forum is phpbb2mysql

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.