>>> Logging In From Main Site - Please Help

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
rhonin
Registered User
Posts: 170
Joined: Sun May 25, 2003 8:54 am

>>> Logging In From Main Site - Please Help

Post by rhonin »

I've asked this before in my previous thread: http://www.phpbb.com/phpBB/viewtopic.php?t=125240


From that I got 2 links:
http://www.ajquick.com/programming/phpbb/tutorial/
http://www.phpbb.com/phpBB/viewtopic.php?t=81607


However from all of that I learned nothing, because I'm missing some parts of what to do - will anyone help me out with this?



One - The "top.php" Page I Need To Include In My Main Sites Header

I have the code for it:
In order to use the PHPbb login on all the pages of your site, you will need to add the correct code to the headers of all of your non-phpbb pages. I hope you used something easy like made a 'top.php' header you included in all the pages, or else you've got a lot of code to insert on every page. I will explain all the code, then have all the code you need later, so don't worry about copying it now.

First part to add, define in phpbb. This was a security measure added in version 2.0.0 of the software. Added to stop people from hacking into your forums, and in this case, even yourself.

define('IN_PHPBB', true);

Now, you will need to include the files PHPbb uses. This should be fairly simple, and easy to do, all you need to change are the absolute paths to your files.

$site_root_path = '/web/etc/you'; //<-- Modify
$phpbb_root_path2 = '/phpbb2/'; //<-- Modify
$phpbb_root_path = $site_root_path . $phpbb_root_path2;
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.php');
include($phpbb_root_path . 'config.php');

Next, you will need to add the user management code, this actually does all the important work. It grabs the userdata from the database for the person if they are logged in. It also will define all the PHPbb variables you will end up using for the parts of your site.

$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);

Well that should be all you need to really actually make users accessible to your site. The very simple code can actually do pretty much all you would want to do, but in the next sections, I will show you how to go the extra mile. Here is the full code for this section:

define('IN_PHPBB', true);

$site_root_path = '/web/etc/you/'; //<-- Modify
$phpbb_root_path2 = '/phpbb2/'; //<-- Modify
$phpbb_root_path = $site_root_path . $phpbb_root_path2;
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.php');

$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);


The problem is this:
- Do I just put all of that code on one page?
- How do I linclude that page in the header? I'm using a link rel for my css style page, but I have no idea how to include a php one...



Two: Making the Login Two Input Bars, Instead of a "Login" "Logout"
+ Making Those Bars Change Into "[Welome "username"]" and "[Logout]" After a Login is Done...


All pretty much included in the topic, which is how do I make the login/logout inputs instead of links?

*Example: http://www.go-gaia.com/



Three: Site Related Posting

On sites such as replayers.com you can not only login at the site, but also if you are logged on post commentary on replays, downloads etc which in turn display right beneath the download details.

This is what I am ultimately trying so hard to do =(


I'm posting this again so maybe it will be a little more clear on what I'm trying to accomplish so I can get help easier.
~Thankyou!
Last edited by rhonin on Sat Aug 09, 2003 9:05 am, edited 4 times in total.
rhonin
Registered User
Posts: 170
Joined: Sun May 25, 2003 8:54 am

Post by rhonin »

Anyone? I gave 2 tutorial links, and an example site. Surely someone has to know =(
rhonin
Registered User
Posts: 170
Joined: Sun May 25, 2003 8:54 am

Post by rhonin »

Is my main post too vague or unclear?
boyinfrance
Registered User
Posts: 295
Joined: Sun Nov 03, 2002 6:58 pm
Location: West Country
Contact:

Post by boyinfrance »

1. This is probably a question more suited to the MOD fora, but what the hey.

This article is presuming your non-phpbb pages are made up like this:

Code: Select all

index.php

<?php
include(header.php);
.....
blah blah....... blah ... blah.... (page content)
....

inlclude(footer.php);
?>
Yes, you put all that code in one page

Code: Select all

header.php

<?php
define('IN_PHPBB', true); 

$site_root_path = '/web/etc/you/'; //<-- Modify 
$phpbb_root_path2 = '/phpbb2/'; //<-- Modify 
$phpbb_root_path = $site_root_path . $phpbb_root_path2; 
include($phpbb_root_path . 'extension.inc'); 
include($phpbb_root_path . 'common.php'); 

$userdata = session_pagestart($user_ip, PAGE_INDEX); 
init_userprefs($userdata);
?>

2. I'm not exactly sure what you mean, could you go into more detail?

3. That's not something that I could really help you with. Try asking in the MOD fora.


:)

I may be totally wrong with this so feel free to correct me
rhonin
Registered User
Posts: 170
Joined: Sun May 25, 2003 8:54 am

Post by rhonin »

T H A N K Y O U ! ! !

In anycase, number two is in regards to logging in (to the forums) from the main site outside of the forums.
What I mean is on the tutorial I linked to it only tells you how to make links to "log in." A [Login] link, which takes you to the login page on the forums, and a [Logout].
What I want to do is allow people to log on right there with username and password inputs (bars you type text into lol).
Look at www.deviantart.com, or www.go-gaia.com they, along with hundreds of other websites do the same thing. Understand?

I don't blame you for not knowing number three, I'll probably need to ask in a dhtml forum.
User avatar
Black Fluffy Lion
Former Team Member
Posts: 6057
Joined: Sat Dec 15, 2001 11:37 am

Post by Black Fluffy Lion »

moved to MOD author support.
User avatar
blueadmin
Registered User
Posts: 124
Joined: Wed May 14, 2003 4:58 pm
Location: Bradford, UK

Post by blueadmin »

for 2 you want the login bit at the top to change to "welcome [username], Logout"?

If so the following code should suffice

Code: Select all

if ( $userdata['session_logged_in'] )
{
        'Welcome ' . $userdata['username'];
$u_login_logout = 'login.'.$phpEx.'?logout=true&sid=' . $userdata['session_id'];
$l_login_logout = $lang['Logout'];
}
else
{
        $u_login_logout = 'login.'.$phpEx;
        $l_login_logout = $lang['Login'];
}
you might have to jigle the logged in parts, i am not sure about the order of that, but this is the general code.
Ho Ho Ho merry christmas
You Stuck? Read this before askinghere and here
rhonin
Registered User
Posts: 170
Joined: Sun May 25, 2003 8:54 am

Post by rhonin »

Is that code for the login input bars, or just for the "login, logout" links?

The main problem for number 2 is that I have no idea how to make the two input bars to type in username and password. Which is why I unfortunatley can't use your help blueadmin - for I have nothing to logout or show usernames from.

I need to find the MOD or script in order to create two input bars (name, pass) and have them change into ([username], logout) respectivley.
User avatar
blueadmin
Registered User
Posts: 124
Joined: Wed May 14, 2003 4:58 pm
Location: Bradford, UK

Post by blueadmin »

This code will put the following down if you are not looged in:

Login

With a link to login.php and if you are logged in with username 'test' it would say:

Welcome test Logout.

If you want to have boxes to login embedded in a page, you would have to look in login.php.
Ho Ho Ho merry christmas
You Stuck? Read this before askinghere and here
rhonin
Registered User
Posts: 170
Joined: Sun May 25, 2003 8:54 am

Post by rhonin »

What do you mean look up login.php? Where is it?

Sorry, I'm not too good at php yet, which is why I was hoping someone would post all the code I needed here. Luckily all I need now is code for the login boxes :D
User avatar
blueadmin
Registered User
Posts: 124
Joined: Wed May 14, 2003 4:58 pm
Location: Bradford, UK

Post by blueadmin »

Login.php is in the root directory.

I will look for the login boxes code, its in here somewhere :)

I'm looking in login_body.tpl in the template directory, i amn seeing the following code:

Code: Select all

 
<form action="{S_LOGIN_ACTION}" method="post" target="_top">

<table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
  <tr> 
        <td align="left" class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a></td>
  </tr>
</table>

<table width="100%" cellpadding="4" cellspacing="1" border="0" class="forumline" align="center">
  <tr> 
        <th height="25" class="thHead" nowrap="nowrap">{L_ENTER_PASSWORD}</th>
  </tr>
  <tr> 
        <td class="row1"><table border="0" cellpadding="3" cellspacing="1" width="100%">
                  <tr> 
                        <td colspan="2" align="center">&</td>
                  </tr>
                  <tr> 
                        <td width="45%" align="right"><span class="gen">{L_USERNAME}:</span></td>
                        <td> 
                          <input type="text" name="username" size="25" maxlength="40" value="{USERNAME}" />
                        </td>
                  </tr>
                  <tr> 
                        <td align="right"><span class="gen">{L_PASSWORD}:</span></td>
                        <td> 
                          <input type="password" name="password" size="25" maxlength="32" />
                        </td>
                  </tr>
                  <tr align="center"> 
                        <td colspan="2"><span class="gen">{L_AUTO_LOGIN}: <input type="checkbox" name="autologin" /></span></td>
                  </tr>
                  <tr align="center"> 
                        <td colspan="2">{S_HIDDEN_FIELDS}<input type="submit" name="login" class="mainoption" value="{L_LOGIN}" /></td>
                  </tr>
                  <tr align="center"> 
                        <td colspan="2"><span class="gensmall"><a href="{U_SEND_PASSWORD}" class="gensmall">{L_SEND_PASSWORD}</a></span></td>
                  </tr>
                </table></td>
  </tr>
</table>

</form>
I will test this to see what it outputs, if it is just the login boxes or it has more to it.

Edit: After checking it out, this looks like the template info you are looking for for the login boxes, so just put this in your template where ever you want your login box and it should work.
Ho Ho Ho merry christmas
You Stuck? Read this before askinghere and here
rhonin
Registered User
Posts: 170
Joined: Sun May 25, 2003 8:54 am

Post by rhonin »

I'm still confused... this is all I need in order to polish off my site so please help me here:


- The include file

Code: Select all

index.php 
<?php 
include(header.php); 
..... 
blah blah....... blah ... blah.... (page content) 
.... 
inlclude(footer.php); 
?> 

Does this go into the head? Please explain the blah blah blah... or does this go around the php code in the page?



-The actual log on code

None of the one's anyone here has given me have worked -_-
example: http://www.go-gaia.com/index.php

Look under the "Sign into Gaia." There is a login, password and "i forgot my password" that is exactly what I'm trying to do and trying to put into a <div> on my page.

Anyone? 8O
User avatar
blueadmin
Registered User
Posts: 124
Joined: Wed May 14, 2003 4:58 pm
Location: Bradford, UK

Post by blueadmin »

try inputting this code:

Edit: upon testing, i realised that neither of those codes would work as the first was mixing html and php, and the second would out-put the {L_ENTER_PASSWORD} as {L_ENTER_PASSWORD}.

if you are using templates, could you include page_header.php for the welcome {username} and the following for the login box withing your template file that shall only show up if you are not logged in.

Code: Select all

<!-- BEGIN switch_user_logged_out -->
<form method="post" action="{S_LOGIN_ACTION}">
  <table width="100%" cellpadding="3" cellspacing="1" border="0" class="forumline">
        <tr>
          <td class="catHead" height="28"><a name="login"></a><span class="cattitle">{L_LOGIN_LOGOUT}</span></td>
        </tr>
        <tr>
          <td class="row1" align="center" valign="middle" height="28"><span class="gensmall">{L_USERNAME}:
                <input class="post" type="text" name="username" size="10" />
                &&&{L_PASSWORD}:
                <input class="post" type="password" name="password" size="10" maxlength="32" />
                && &&{L_AUTO_LOGIN}
                <input class="text" type="checkbox" name="autologin" />
                &&&
                <input type="submit" class="mainoption" name="login" value="{L_LOGIN}" />
                </span> </td>
        </tr>
  </table>
</form>
<!-- END switch_user_logged_out -->
Ho Ho Ho merry christmas
You Stuck? Read this before askinghere and here
rhonin
Registered User
Posts: 170
Joined: Sun May 25, 2003 8:54 am

Post by rhonin »

How do I include the php file in the header?
User avatar
blueadmin
Registered User
Posts: 124
Joined: Wed May 14, 2003 4:58 pm
Location: Bradford, UK

Post by blueadmin »

Code: Select all

include page_header.php
from within the .php page will output all from the forum image to logout [{username}].
Ho Ho Ho merry christmas
You Stuck? Read this before askinghere and here
Post Reply

Return to “[2.0.x] MOD Writers Discussion”