php login box in the index

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Get Involved
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
Locked
Ruko
Registered User
Posts: 89
Joined: Tue Aug 04, 2009 9:32 pm

php login box in the index

Post by Ruko »

how do i create a php login box in the homepage (Not the forums index)

Can you show stuff like, when the user is logged in, instead of the login forum, it will say "You are logged in. Click here to proceed to the forum"

my directory of the forum is /forum/
Ruko
Registered User
Posts: 89
Joined: Tue Aug 04, 2009 9:32 pm

Re: php login box in the index

Post by Ruko »

any1?
Tom
Former Team Member
Posts: 2665
Joined: Tue Jun 20, 2006 2:12 am
Name: Tom
Contact:

Re: php login box in the index

Post by Tom »

Here is a topic that will put you on the right track: http://www.phpbb.com/community/viewtopi ... 1&t=719055
Tom C. - Former Moderator Team Member
phpBB3 Smiley Pak Generator | Legend Repositioning MOD | My GitHub | My Site
Ruko
Registered User
Posts: 89
Joined: Tue Aug 04, 2009 9:32 pm

Re: php login box in the index

Post by Ruko »

Thanks, i have another problem too. when i paste a code, i receive this error

Code: Select all

Parse error: syntax error, unexpected T_STRING in /home2/pokelab/public_html/index.php on line 13
the code i used

Code: Select all

<?php
    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();

    if($user->data['is_registered'])
    {
        echo "Welcome " . $user->data['username']; //User is already logged in
    }
    else if(isset($_POST['login']))
    {
        $username = request_var('username', '', true);
        $password = request_var('password', '', true);
        $autologin = (!empty($_POST['autologin'])) ? true : false;

        $result = $auth->login($username, $password, $autologin);

        if ($result['status'] == LOGIN_SUCCESS)
        {
            //User was successfully logged into phpBB
            $redirect = request_var('redirect', "{$phpbb_root_path}index.$phpEx");

            // append/replace SID
            $redirect = reapply_sid($redirect);

            meta_refresh(0, $redirect);
            trigger_error('You have been logged in');
        }
        else
        {
            echo 'Bad Login ' . $username; //User's login failed
        }
    }
    else
    {
        echo '
            Please log in:<br />
            <form method="POST" action="_SELF">
            <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>
            </form>';
    }
    ?>
Tom
Former Team Member
Posts: 2665
Joined: Tue Jun 20, 2006 2:12 am
Name: Tom
Contact:

Re: php login box in the index

Post by Tom »

Are you sure you have the correct path defined for the $phpbb_root_path variable? Based on the directory structure shown in the error message you posted, shouldn't the root path be ./forum/ (with one period) instead of ../forum/ (with two periods)?
Tom C. - Former Moderator Team Member
phpBB3 Smiley Pak Generator | Legend Repositioning MOD | My GitHub | My Site
Ruko
Registered User
Posts: 89
Joined: Tue Aug 04, 2009 9:32 pm

Re: php login box in the index

Post by Ruko »

Fixed that and didn't do a thing.
User avatar
Lumpy Burgertushie
Registered User
Posts: 68880
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: php login box in the index

Post by Lumpy Burgertushie »

am I lost? this won't work because the user has not logged in yet. so the username varible can't print the username?

Code: Select all

else
        {
            echo 'Bad Login ' . $username; //User's login failed
robert
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.3 Styles by PlanetStyles.net

I am pleased to announce that I have completed the first item on my bucket list. I have the bucket.
User avatar
Lumpy Burgertushie
Registered User
Posts: 68880
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: php login box in the index

Post by Lumpy Burgertushie »

how about a link to your board so we can give you exact instructions.


robert
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.3 Styles by PlanetStyles.net

I am pleased to announce that I have completed the first item on my bucket list. I have the bucket.
Ruko
Registered User
Posts: 89
Joined: Tue Aug 04, 2009 9:32 pm

Re: php login box in the index

Post by Ruko »

http://pokelab.co.tv is my web link.

the directory of the forum is "/forums

I changed the "forum" in the script to "forums"
Locked

Return to “[3.0.x] Support Forum”