- Messages
- 4,467
- Reaction score
- 95
- Points
- 0
We can use the login/session manager in phpbb 3 as our main sitewide login system. This way, we only have to include the php to link our files with the phpbb session manager, and not write it ourself (hours of debuging spared... trust me!)
Here is the code that should be in the file config.php, placed in your root website directory (accessible on the web)
Place the following code in it and modify it so that it is configured for your installation.
Now this is the code of a page that displays some information to logged in users.
You find my post helpful, donate or add me rep.
Here is the code that should be in the file config.php, placed in your root website directory (accessible on the web)
Place the following code in it and modify it so that it is configured for your installation.
PHP:
<?php
// config.php
define('IN_PHPBB', true);
$phpbb_root_path = 'phpBB3/'; //modify this to point to the root path of your phpbb 3 installation.
$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);
$user->setup();
?>
PHP:
<?php
//check_user.php
require_once 'config.php';
?>
<html>
<head>
</head>
<body>
Some content
<?php
if($user->data['is_registered'])
{
//user is logged in
echo 'Welcome back, ' . $user->data['username'];
} else
{
//user is not logged in
?>
Please log in:<br />
<form method="POST" action="./<?php echo $phpbb_root_path ?>ucp.php?mode=login">
<p>Username: <input type="text" name="username" size="40"><br />
Password: <input type="password" name="password" size="40"><br />
Remember Me?: <input type="checkbox" name="autologin"><br />
<input type="submit" value="Submit" name="login"></p>
<input type="hidden" name="redirect" value="index.php">
<!-- The value off the redirect hidden input may be modified,
but you need to keep in mind that the wording directory will
be not the directory of the script, but of the forum. -->
</form>
<?php
}
?>
More content
</body>
</html>
You find my post helpful, donate or add me rep.
Last edited: