Dailytip.net

Articles on pretty much anything.

About the author

Author Name is someone.
E-mail me Send mail

Recent posts

Recent comments

Tags

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008


Integrating phpBB3 login on your sites

Have you ever wanted to allow your users to sign into their phpBB 3 accounts from your homepage? In this tutorial, I'm going to show you how!

All you need is:

  1. A web host with PHP and MySQL.
  2. An installed copy of phpBB 3.
  3. A website to integrate it with.

Hit more to see the rest of the tutorial

Integrating phpBB 3's login is actually very simple. All it involves is pasting (and editing where necessary) a single piece of code, and here it is:

<form method="post" action="http://www.PATHTOYOURFORUMS/ucp.php?mode=login">

<p><input name="username" type="text" id="username" /></p>

<p><input name="password" type="password" id="password" /></p>

<p><input name="redirect" value="where/to/go/after/login" type="hidden">

<input name="login" class="mainoption" value="Log in" type="submit"></p>

</form>

Place this code (or similar code to suit your needs) into your templates login area. The most important parts of this code, and the bits it cannot function without are:

<form method="post" action="http://www.PATHTOYOURFORUMS/ucp.php?mode=login">

Without this piece of code, the form doesn't know where to send the details to; and without the details being sent to the right place, the login won't get processed. Make sure you change "http://www.PATHTOYOURFORUMS/" to your forums domain and folder (EG "www.dailytip.net/forum/"). Also, each input tag needs to keep its name no matter what. Without the names being as they are, phpBB 3 cannot get hold of the details the user has submitted.

The final piece of important code tells the script where to send users who have successfully logged in.

<input name="redirect" value="where/to/go/after/login" type="hidden">

Change the value to the place you want users to be sent; for example "./forums/" or "index.php".

I hope this short tutorial helped you on your way. 

 

Currently rated 4.5 by 12 people

  • Currently 4.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by Andy on Thursday, March 06, 2008 10:00 PM
Permalink | Comments (22) | Post RSSRSS comment feed

Related posts

Comments

Colin us

Friday, March 21, 2008 7:17 AM

Colin

Not bad, I was hoping you would show how to integrate it as in connecting to phpbb's database and using the user info on the main site.

Fenix ca

Friday, March 21, 2008 7:33 AM

Fenix

Hey sure, we'll get the article up within this week. Thanks for the recomendation.

Raukey us

Monday, March 24, 2008 4:11 PM

Raukey

HI ,THx for the code but i have another question
How to use the above code in main site, if not to change the domain name.

Raukey us

Monday, March 24, 2008 4:17 PM

Raukey

I am trying to do the following, I want the users in my webpage to be able to login to the forum through the website and to be able to access the forum, also, I want user not have to log into forum if he is already logged in by logging in site.
What files should I include in the main site to handle this information.

Andy gb

Monday, March 24, 2008 11:53 PM

Andy

Hi, Raukey.

Thank you for your response. It will be a little hard for me to explain the solution to your problem right here. If you'd like to wait until Friday 24th March I will include a solution for this in my more detailed article of the integration of phpBB 3.

Regards,
Andy.

Raukey us

Tuesday, March 25, 2008 10:39 PM

Raukey

Hi,
thx, that will be grate. I am trying this way and not finding whats wrong wth the code. Please suggest me .
<form name="log" action="phpBB3/ucp.php?mode=login" method="post">
<input class="post" type="text" name="username" size="25" value="<?=$username?>" tabindex="1" />
<input class="post" type="password" name="password" size="25" tabindex="2" value="<?=$password?>" />
<input type="checkbox" class="radio" name="autologin" tabindex="3" />
<input type="checkbox" class="radio" name="viewonline" tabindex="4" />
<input type="hidden" name="redirect" value="../log_in_01_success.php" />
<input type="hidden" name="sid" value="<?=$_SESSION[sid]?>" />
<input type="submit" value="go">
</form>
I am auto subbmiting it, but it will take me to the loging form of thr phpBB3 forum while i have paased the username and password.
thx and waiting for you sulution and artical.

Andy gb

Monday, March 31, 2008 4:19 PM

Andy

I'm not sure what's wrong there, Raukey. I do know, however, that the session ID isn't kept in a session. You can either obtain it from the query string using $_REQUEST or get it from the user data in the user class accessed through $user->data.

If you need any further assistance, feel free to email me your IM details and I will contact you.

acctman us

Saturday, April 05, 2008 3:24 AM

acctman

dont must people want the opposite? people usually already have an existing site with login and they want to add a forum. phpbb3 doesnt seem to want to play nice when being added as a 3rd party addon

Andy gb

Saturday, April 05, 2008 1:58 PM

Andy

Some people will want that, obviously; but the majority of cases I've heard of and the majority of people I've spoken to want it this way - usually because they can't afford to have a CMS, or user system, built for them. Other times they may be using a template with a login box, such as many of the templates made by the wonderful staff and crew over at http://www.clantemplates.com/, and wish to be able to use that feature functionally, instead of leaving it to sit there as a pretty ornament.

The other, slightly more relevant, point is that it would be a very heavy job (see: big work-load) to convert the WHOLE of phpBB 3, or any other forum software for that matter, to use a custom user system; it just wasn't built to work like that.

Thanks for reading and replying aactman. I'll consider looking into converting phpBB 3 to use a new user system - but I fear the method may be too complex to post here and may well be better off at a programming\scripting forum.

Skl epy

Saturday, April 05, 2008 6:48 PM

Skl epy

Works great.
I think it's good idea to write a blog about integrating scripts. Got to do it!

acctman us

Sunday, April 06, 2008 8:45 AM

acctman

andy, i've given it some thought and actually it would be all that hard to do. if cookie session were used (which hold the users login and pass)

ex. 1. user logs into cms
2. take cookie pass it to phpbb3 login check
3. custom code check to see if user is already in phpbb3 user db, if not then add username and/or pass.
4. user would have to create there own delete user code to tie into there cms delete user code.

thats the easiest way i see it being done. then show the use how they can hide the phpbb3 login screen. so now when user logs into cms they're autologged into phpbb3.

Andy gb

Sunday, April 06, 2008 4:49 PM

Andy

Aactman. The way you described is still an integration of the phpBB 3 user system. If users already have a CMS with user system, they can easily change their CMS to use the user table, and object, from the phpBB 3 installation - which will manage all the logging in and out - and then use the phpBB 3 login code I gave you above to login.

Usman gb

Wednesday, June 11, 2008 10:13 AM

Usman

I just want to say thank you for this tutorial. I was thinking of doing this all myself but then saw this. It is great and should rapidly change my site.

I wanted your help. The redirect code <input> etc. doesn't work for me. It redirects to my forum. I put in index.php but it still happens. I want the user to be redirected to the home page of my site.

Thank you.

Andy gb

Wednesday, June 11, 2008 10:34 AM

Andy

Are you sure you are changing the correct bit of the HTML?

<input name="redirect" value="homepage.html" type="hidden">
The redirect input should look a little like that.

If this continues, email me a copy of the code. (Use http://yourname.pastebin.com to host it. Replace "yourname" with .. your name)

Usman gb

Wednesday, June 11, 2008 11:59 AM

Usman

Yes, this is what my code looks like for that line.
<input name="redirect" value="index.php" type="hidden">

Is this right?

Here is the test page on which I am testing it out.
http://www.yourmediaking.com/index.php

I have just installed my forum. I am also in my theory stage of designing my website. Please note that the link above is different from the home page. That's the page which will be home when my site goes live.

Thank you.

Andy gb

Wednesday, June 11, 2008 2:39 PM

Andy

OK. That's correct. One problem is though, the URL you supply there is relative to the phpBB3 installation. Therefore if you put your forum in a folder called forum, it is relative to that folder. So to access a file in the parent folder you would place "../" before the file name or "./" to get something in the same directory.

Hope that helped.

Usman gb

Wednesday, June 11, 2008 3:01 PM

Usman

Thank you, that worked perfectly! But would there be any chance of not seeing the forum page?

Andy gb

Wednesday, June 11, 2008 3:49 PM

Andy

What do you mean by "not seeing the forum page"? If its going to the forum page and then redirecting, I don't believe you can stop it doing that very easily - it would probably require you to modify the source files.

Usman gb

Wednesday, June 11, 2008 4:35 PM

Usman

Never mind, I just wanted users to be logged in and immediately see the site home page rather than be redirected from the forum. But I have come up with a workaround. This is where I can customise the forum SO much that it matches my normal template. This way the users won't notice a drastic change.

Hey Andy, would it be possible to use the PHPBB3 main system and functionality to private message (and other functions) other registered users while ON THE MAIN WEBSITE (not forum).

This would be really cool if possible, is it?

Andy gb

Thursday, June 12, 2008 3:59 AM

Andy

It would be possible yes, though you would need a good, working knowledge of PHP to manipulate its methods and work with it's security. Once you manage to work around\with that I imagine it would be quite easy.

Jos nl

Saturday, June 21, 2008 3:45 PM

Jos

You should use a syntax highlighter for your tutorials.

Andy gb

Sunday, June 22, 2008 1:56 AM

Andy

Believe me, Jos, we would if we could find a decent one! None of them seem to come out very well.

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

Saturday, July 05, 2008 3:21 AM