2011-02-23 116 views
6

我已經將phpbb3論壇集成到了我現有的網站。phpBB3自動登錄

我已經能夠讓我的註冊過程添加用戶到phpbb數據庫以及。

現在我面臨一個問題,我試圖讓用戶在登錄我的網站時自動登錄論壇。

有沒有人在這裏做過?我找不到與Google相關的任何內容,因爲所有帖子似乎都在討論「phpbb external webpages」以及如何在其他網頁上使用phpbb會話。然而,我想要做的只是當成員登錄到我的網站時發起登錄,並且遵循我在google上發現的教程將讓我的用戶在登錄我的論壇時登錄到我的網站(這是另一種方式)。

感謝

回答

4
<?php 
    define('IN_PHPBB', true); 
    $phpbb_root_path = '../phpBB3/'; //the path to your phpbb relative to this script 
    $phpEx = substr(strrchr(__FILE__, '.'), 1); 
    include("../phpBB3/common.php"); ////the path to your phpbb relative to this script 
    // Start session management 
    $user->session_begin(); 
    $auth->acl($user->data); 
    $user->setup(); 

    $username = request_var('username', 'john'); 
    $password = request_var('password', '123'); 

    if(isset($username) && isset($password)) 
    { 
     $result=$auth->login($username, $password, true); 
     if ($result['status'] == LOGIN_SUCCESS) { 
     echo "You're logged in"; 
     } else { 
     echo $user->lang[$result['error_msg']]; 
     } 
    } 
?> 
+0

謝謝!你是如何得到他的信息的?它是否也適用於絕對paht? – Adam 2016-10-10 19:02:24