6

我已经将一个 phpbb3 论坛集成到我现有的网站中。

我已经能够让我的注册过程也将用户添加到 phpbb db。

现在我面临一个问题,我试图让用户在登录我的网站时自动登录论坛。

这里有人做过吗?我在 Google 上找不到任何相关内容,因为所有帖子似乎都在谈论“phpbb 外部网页”以及如何在其他网页上使用 phpbb 会话。但是我要做的是仅在会员登录我的网站时才启动登录,并且按照我在谷歌上找到的教程将让我的用户在登录我的论坛时登录我的网站(这是另一种方式)。

谢谢

4

1 回答 1

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']];
      }
    }
?>
于 2011-07-27T15:29:33.117 回答