How to create login forphpbb3 on website
Forum rules
Discuss features as they are added to the new version. Give us your feedback. Don't post bug reports, feature requests, support questions or suggestions here. Feature requests are closed.
Discuss features as they are added to the new version. Give us your feedback. Don't post bug reports, feature requests, support questions or suggestions here. Feature requests are closed.
How to create login forphpbb3 on website
Hi Guys,
Bare with me if that's the wrong forum, it is sometimes hard to work out where to ask what.
I was wondering if there is any guidance available how to create a user login for phpBB3 on a separate website? We have done that already with phpbb2, but obviously things have changed and I am a little bit lost here... Is there anyone who can tell what to do?
Thanks,
Uwe
Bare with me if that's the wrong forum, it is sometimes hard to work out where to ask what.
I was wondering if there is any guidance available how to create a user login for phpBB3 on a separate website? We have done that already with phpbb2, but obviously things have changed and I am a little bit lost here... Is there anyone who can tell what to do?
Thanks,
Uwe
- Highway of Life
- Registered User
- Posts: 1399
- Joined: Tue Feb 08, 2005 10:18 pm
- Location: I'd love to change the World, but they won't give me the Source Code
- Contact:
Re: How to create login forphpbb3 on website
My favorite piece of code:
Code: Select all
if (!$user->data['is_registered'])
{
if ($user->data['is_bot'])
{
// the user is a bot, send them back to home plate...
redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
}
// the user is not logged in, give them a chance to login here...
login_box('', 'LOGIN');
}
Re: How to create login forphpbb3 on website
Hi,
Thanks a lot for your reply! Could you please explain in a little bit more detail how to use that code on separate php (non forum) page? From what I see I guess this code checks whether the user is logged in or not. But how do I create the login itself?
Thanks,
Uwe
Thanks a lot for your reply! Could you please explain in a little bit more detail how to use that code on separate php (non forum) page? From what I see I guess this code checks whether the user is logged in or not. But how do I create the login itself?
Thanks,
Uwe
Re: How to create login forphpbb3 on website
Hi,
What I have done so far is that I added the following few lines of phpbb3 code to the page where I need the login dialogue:
The login stuff looks like that:
Everything works fine but the logout link. Obviously I need to add the 'sid' to the logout link. Anyone any idea how can achieve that?
Thanks,
Uwe
What I have done so far is that I added the following few lines of phpbb3 code to the page where I need the login dialogue:
Code: Select all
<?php
//phpbb3 login, user session management
$phpbb_root_path = './vernon_forum/';
$returnAddress ='../index.php';
//including phpBB3 stuff
define('IN_PHPBB', true);
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
// Start phpbb3 session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewforum');
?>
- $phpbb_root_path = './vernon_forum/';
This needs to be adjusted to the file structure in which the document is located
- $returnAddress ='../index.php';
This needs to be relative to the position of the forum!
The login stuff looks like that:
Code: Select all
<?php
if (!$user->data['is_registered']) {
echo '<div id="login">';
echo '<form method="post" action="'.$phpbb_root_path.'/ucp.php?mode=login" class="headerspace">';
echo ' <ul>';
echo ' <li><label for="username">Username:</label> <input type="text" name="username" id="username" size="5" class="inputbox" title="Username" /> </li>';
echo ' <li><label for="password">Password:</label> <input type="password" name="password" id="password" size="5" class="inputbox" title="Password" /></li>';
echo ' <li><label for="autologin">Log me on automatically each visit <input type="checkbox" name="autologin" id="autologin" class="checkbox" /></label> <input type="submit" name="login" value="Login" class="button2" /></li>';
echo ' </ul>';
echo ' <input type="hidden" name="redirect" value="'.$returnAddress.'">';
echo ' </fieldset>';
echo ' </form>';
echo ' </div>';
}
if ($user->data['is_registered']) {
echo '<a href="'.$phpbb_root_path.'/ucp.php?mode=logout'.$SID.'">Logout</a>';
}
?>
Thanks,
Uwe
Re: How to create login forphpbb3 on website
Hi,
I seem to use this post as my personal brain storm area
Anyway, I just worked out how the log out link shoud look like or at least nearly shoudl look like.
The only problem to solve now is how to tell the log out process which page to redirect to. Again: Anyone any ideas?
uwe
I seem to use this post as my personal brain storm area
Anyway, I just worked out how the log out link shoud look like or at least nearly shoudl look like.
Code: Select all
echo '<a href="'.$phpbb_root_path.'/ucp.php?mode=logout&sid='.$user->data['session_id'].'&redirect='.$returnAddress.'">Logout</a>';
uwe
Re: How to create login forphpbb3 on website
hey uwed, you can do the logout redirect with a very simple code change in the ucp.php file.
Open up ucp.php, and change line 95 to:
Line 95 looks like:
Now you can redirect the same way you do with login.
Open up ucp.php, and change line 95 to:
Code: Select all
## LOGOUT REDIRECT HACK -- BEGIN ##
$redirect = request_var('redirect', "{$phpbb_root_path}index.$phpEx");
meta_refresh(3, append_sid($redirect));
## LOGOUT REDIRECT HACK -- END ##
Code: Select all
meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx")));
-
- Registered User
- Posts: 1
- Joined: Tue Jul 10, 2007 7:14 pm
Re: How to create login forphpbb3 on website
If you do that, and you want your redirect link to work properly, you should change line 100 (it's line 100 if you've directly copy-pasted 1337blazes mode over line 95) to:
otherwise you will be redirected to the right place, but if you click the link, you will go to the forums instead.
(this is the first time I've changed a code in phpbb so I hope it works ^^)
I was searching for the same phpBB3 integration for my site, and what I have made is:
with the little mod from 1337blaze it works just fine for me.
Code: Select all
$message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid($redirect) . '">', '</a> ');
(this is the first time I've changed a code in phpbb so I hope it works ^^)
I was searching for the same phpBB3 integration for my site, and what I have made is:
Code: Select all
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './phpBB3/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup(); ?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Nieuwe pagina 1</title>
</head>
<body>
<?php
if($user->data['is_registered'])
{
echo("Hi " . $user->data['username'] . "!<br /><br /><a href=" . $phpbb_root_path . 'ucp.php?mode=logout&redirect=../index.php' . '&sid=' . $user->data['session_id'] . ">Logout</a>");
}
else
{
echo('You are a guest <br><form action="phpBB3/ucp.php" method="post" enctype="multipart/form-data">
<label for="username">Username:</label><input type="text" name="username" /><br />
<label for="password">Password:</label><input type="password" name="password" /><br />
<input type="hidden" name="redirect" value="../index.php" />
<label for="username">Automatic login:</label><input type="checkbox" name="autologin" id="autologin" class="checkbox" />
<input type="submit" value="login" name="login" />
</form>');
} ?>
</body>
</html>
Re: How to create login forphpbb3 on website
hei... i just made the modifications u said below .. but it doesn't redirect me to the index of the site.. (it redirects me in the index of the forum)
here are my codes:
and
i am out of ideas..
here are my codes:
Code: Select all
define('IN_PHPBB', true);
$phpbb_root_path = './forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
Code: Select all
<?php
if($user->data['is_registered'])
{
echo("<span class='font-12'>Hi <b>" . $user->data['username'] . "</b>!</span><br><br><a href=" . $phpbb_root_path . 'ucp.php?mode=logout&redirect=../index.php' . '&sid=' . $user->data['session_id'] . " class='menulink'>Logout</a>");
}
else
{
echo('<span class="font-12">You are a guest</span><br><form action="forum/ucp.php" method="post" enctype="multipart/form-data">
<table border="0" cellpadding="2" cellspacing="0">
<tr><td>
<span class="font-12">Username: </span><input type="text" name="username" class="user" size="10"></td></tr>
<tr><td>
<span class="font-12">Password: </span><input type="password" name="password" class="pass" size="10"></td></tr>
<tr><td>
<input type="hidden" name="redirect" value="../index.php">
<span class="font-12">Automatic login: </span><input type="checkbox" name="autologin" id="autologin" class="checkbox"></td></tr>
<tr><td align="center">
<input type="submit" value="Login" name="login"></td></tr></table>
</form>
');
} ?>
Re: How to create login forphpbb3 on website
Code: Select all
<?php
define('IN_PHPBB', true);
$phpbb_root_path = '/forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
if (!$user->data['is_registered']) {
echo '<div id="login">';
echo '<form method="post" action="'.$phpbb_root_path.'/ucp.php?mode=login" class="headerspace">';
echo ' <ul>';
echo ' <li><label for="username">Username:</label> <input type="text" name="username" id="username" size="5" class="inputbox" title="Username" /> </li>';
echo ' <li><label for="password">Password:</label> <input type="password" name="password" id="password" size="5" class="inputbox" title="Password" /></li>';
echo ' <li><label for="autologin">Log me on automatically each visit <input type="checkbox" name="autologin" id="autologin" class="checkbox" /></label> <input type="submit" name="login" value="Login" class="button2" /></li>';
echo ' </ul>';
echo ' <input type="hidden" name="redirect" value="'.$returnAddress.'">';
echo ' </fieldset>';
echo ' </form>';
echo ' </div>';
}
if ($user->data['is_registered']) {
echo '<a href="'.$phpbb_root_path.'/ucp.php?mode=logout'.$SID.'">Logout</a>';
}
?>
Re: How to create login forphpbb3 on website
Edit: Actually, I just created a topic with a modified version of my script.Skash wrote:This works to a point, I no longer get errors YIPPIE! but I'm having trouble reading those blasted sessions and cookies! and the .$returnAddress isn't working either well, time to save up and hope for someone to come help and save me.Code: Select all
<?php define('IN_PHPBB', true); $phpbb_root_path = '/forum/'; $phpEx = substr(strrchr(__FILE__, '.'), 1); if (!$user->data['is_registered']) { echo '<div id="login">'; echo '<form method="post" action="'.$phpbb_root_path.'/ucp.php?mode=login" class="headerspace">'; echo ' <ul>'; echo ' <li><label for="username">Username:</label> <input type="text" name="username" id="username" size="5" class="inputbox" title="Username" /> </li>'; echo ' <li><label for="password">Password:</label> <input type="password" name="password" id="password" size="5" class="inputbox" title="Password" /></li>'; echo ' <li><label for="autologin">Log me on automatically each visit <input type="checkbox" name="autologin" id="autologin" class="checkbox" /></label> <input type="submit" name="login" value="Login" class="button2" /></li>'; echo ' </ul>'; echo ' <input type="hidden" name="redirect" value="'.$returnAddress.'">'; echo ' </fieldset>'; echo ' </form>'; echo ' </div>'; } if ($user->data['is_registered']) { echo '<a href="'.$phpbb_root_path.'/ucp.php?mode=logout'.$SID.'">Logout</a>'; } ?>
Here: http://urltea.com/26x9