phpBB login integration

The place to be if you need help with any phpacademy tutorials.

phpBB login integration

Postby dars » Tue Mar 09, 2010 11:35 pm

Hi. I wanted to use the code alex wrote for my login on my homepage. as i pasted the code in the proper place and refreshed my pade it gives me an error in the sign on box.

[php]
"; else { //find username $find = mysql_query("SELECT * FROM phpbb_users WHERE username_clean='$username'"); if (mysql_num_rows($find)==0) echo "Username not found

"; else { while ($find_row = mysql_fetch_assoc($find)) { // grab password hash for user $password_hash = $find_row['user_password']; } $check = phpbb_check_hash($password, $password_hash); if ($check==FALSE) echo "Incorrect password

"; else if ($check==TRUE) { $_SESSION['username']=$username; header("Location: main.php"); exit(); } } } } ?>[/php]

it displays that. Im not all to sure what this means exactly but i hope someone here can help me. i am a novice lol

thanx in advance.
http://phpacademy.info/forum/viewtopic.php?f=26&t=856
dars
 
Posts: 7
Joined: Tue Mar 09, 2010 10:40 pm
Online: 0s
Karma: 0

Re: phpBB login integration

Advertisment

Advertisment
 

Re: phpBB login integration

Postby bowersbros » Tue Mar 09, 2010 11:50 pm

Is that whats displaed on page? If so, quotes somewhere are messed up, or php tag or something :)

Post your full code
The early bird catches the worm but the second mouse gets the cheese!

If you look like your passport picture, you probably need the trip.

---

IM contact details:
Example doesnt work, requires a href
bowersbros
Top Contributor
 
Posts: 2019
Joined: Tue Apr 21, 2009 7:55 pm
Location: United Kingdom
Online: 4d 10h 49m 56s
Karma: 6

Re: phpBB login integration

Postby dars » Wed Mar 10, 2010 12:34 am

[php]<?php

//ob
ob_start();

//session
session_start();

if (isset($_SESSION['username']))
{
header("Location: main.php");
exit();
}

//connect
$error = 'Could not connect to the database';
mysql_connect('localhost','c809189_dars','026140') or die($error);
mysql_select_db('c809189_forum') or die($error);

//include functions.php phpbb script
require 'phpBB3/includes/functions.php';

if ($_POST['login'])
{
//get form data
$username = addslashes(strip_tags(strtolower($_POST['username'])));
$password = addslashes(strip_tags($_POST['password']));

if (!$username||!$password)
echo "Please enter a username and password<p />";
else
{
//find username
$find = mysql_query("SELECT * FROM phpbb_users WHERE username_clean='$username'");
if (mysql_num_rows($find)==0)
echo "Username not found<p />";
else
{
while ($find_row = mysql_fetch_assoc($find))
{
// grab password hash for user
$password_hash = $find_row['user_password'];
}

$check = phpbb_check_hash($password, $password_hash);
if ($check==FALSE)
echo "Incorrect password<p />";
else if ($check==TRUE)
{
$_SESSION['username']=$username;
header("Location: main.php");
exit();
}

}
}



}

?>[/php]

this is the whole code for the logins
dars
 
Posts: 7
Joined: Tue Mar 09, 2010 10:40 pm
Online: 0s
Karma: 0

Re: phpBB login integration

Postby manolo2111 » Thu Mar 11, 2010 12:01 pm

Hello everybody.

I watched this tutorial: http://bit.ly/arJpDr and all worked fine.

When I am logged, I insert a "include("index.php");" to include my forum in the page. But phpBB request me my user and pass again. Which vars I need to generate to inform phpBB that I am registered well?

Thanks a lot.
manolo2111
 
Posts: 2
Joined: Thu Mar 11, 2010 10:20 am
Online: 0s
Karma: 0

Re: phpBB login integration

Postby dars » Thu Mar 18, 2010 1:02 am

ok well that didnt really help. as stand alone the php script works great! however as soon as i include it in my html i get an error. its like its not fitting in right...round hole square peg type deal.

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

   <title>TLMC</title>

    <link rel="stylesheet" type="text/css" href="perfect.css" />

    <script type="text/javascript">

      <!--

      function ctRoster(usrName)

      {

         var collection = usrName;

      

         document.getElementById('roster_name').innerHTML = collection;

      }

      function ctRosterClean()

      {

         document.getElementById('roster_name').innerHTML = "Hover Above";

      }

      // -->

   </script>

</head>

<body>

<div id="container">

   <div id="banner"></div>

    <ul id="nav">

       <li><a href="index.html" id="home"><span><img src="i/home_roll.jpg" alt="" /></span></a></li>

        <li><a href="forums.html" id="forums"><span><img src="i/forums_roll.jpg" alt="" /></span></a></li>

        <li><a href="about.html" id="about"><span><img src="i/about_roll.jpg" alt="" /></span></a></li>

        <li><a href="matches.html" id="matches"><span><img src="i/matches_roll.jpg" alt="" /></span></a></li>

        <li><a href="roster.html" id="roster"><span><img src="i/roster_roll.jpg" alt="" /></span></a></li>

        <li><a href="contact.html" id="contact"><span><img src="i/contact_roll.jpg" alt="" /></span></a></li>

    </ul>

    <div id="left">

       <div id="user_area"></div>

        <div class="content">
<?php

//ob
ob_start();

//session
session_start();

if (isset($_SESSION['username']))
{
header("Location: main.php");
exit(); 
}

//connect
$error = 'Could not connect to the database';
mysql_connect('localhost','','') or die($error);
mysql_select_db('c809189_forum') or die($error);

//include functions.php phpbb script
require 'phpBB3/includes/functions.php';

if ($_POST['login'])
{
//get form data
$username = addslashes(strip_tags(strtolower($_POST['username'])));
$password = addslashes(strip_tags($_POST['password']));

if (!$username||!$password)
    echo "Please enter a username and password<p />";
else
{
  //find username
  $find = mysql_query("SELECT * FROM phpbb_users WHERE username_clean='$username'");
  if (mysql_num_rows($find)==0)
     echo "Username not found<p />";
  else
  {
   while ($find_row = mysql_fetch_assoc($find))
   {
    // grab password hash for user
    $password_hash = $find_row['user_password'];
   }
   
   $check = phpbb_check_hash($password, $password_hash);
   if ($check==FALSE)
      echo "Incorrect password<p />";
   else if ($check==TRUE)
   {
    $_SESSION['username']=$username;
    header("Location: main.php");
    exit();
   }
  }
}
}

?>

         <form action="" method="get">

               <div id="form">

                    <input type="text" value="username" class="input_box" />

                    <input type="text" value="password" class="input_box" />

                </div>

                <div id="submit">

                   <input type="submit" value="" id="go" />

                     <input type="button" value="" id="reg" />

                </div>

            </form>

            <div class="clear"></div>

        </div>

        <div id="latest_matches"></div>

        <ul>

            <li>Virtue Vs Fluffy Multi-Coloured Penguins</li>

            <li>Virtue Vs Fluffy Multi-Coloured Penguins</li>

            <li>Virtue Vs Fluffy Multi-Coloured Penguins</li>

            <li>Virtue Vs Fluffy Multi-Coloured Penguins</li>

            <li>Virtue Vs Fluffy Multi-Coloured Penguins</li>

        </ul>

        <a href="" class="archive"></a>

      <div id="quick_roster"></div>

        <div class="content">

            <a href="" onmouseover="ctRoster('Eon');" onmouseout="ctRosterClean();"><img src="i/roster1.jpg" alt="" /></a>

            <a href="" onmouseover="ctRoster('TerrorKalle');" onmouseout="ctRosterClean();"><img src="i/roster2.jpg" alt="" /></a>

            <a href="" onmouseover="ctRoster('RMLR');" onmouseout="ctRosterClean();"><img src="i/roster3.jpg" alt="" /></a>

            <a href="" onmouseover="ctRoster('ThePerfectCrime');" onmouseout="ctRosterClean();"><img src="i/roster4.jpg" alt="" /></a>

            <a href="" onmouseover="ctRoster('Andrei');" onmouseout="ctRosterClean();"><img src="i/roster5.jpg" alt="" /></a>

            <a href="" onmouseover="ctRoster('serenity');" onmouseout="ctRosterClean();"><img src="i/roster6.jpg" alt="" /></a>

            <div id="roster_name">Hover Above</div>   

            <a href="" class="archive"></a>     

        </div>

        <div id="our_sponsors"></div>

        <a href="http://www.clantemplates.com" id="ct"></a>

        <a href="http://www.briteon.net/" id="be"></a>

        <a href="http://www.dornblaser.info" id="dornblaser"></a>

    </div>

    <div id="right">

       <div class="content_top"></div>

        <div class="right_content">

           <div class="left_box">

               <div class="avi"><img src="i/avi.jpg" alt="" /></div>

                <div class="left_box_right">

                USER: <a href="">Eon</a><br />

                RANK: Chief<br />

                <img src="i/online.jpg" alt="" />

                </div>

                REP: 98<br />

                WEBSITE: <a href="http://www.halotrilogy.org">teamvirtue.com</a>

            </div>

            <div class="right">

               <h1>..</h1>

                <p>..</p>



                <p>..</p>

               

                <p>..</p>



               

               

                <p>:</p>

               

                <p>..</p>
                <p>..</p>

               

                <p>..</p>

            </div>

            <div class="clear"></div>

            <div class="content_foot"></div>

        </div>

       <div class="content_top"></div>

        <div class="right_content">

           <div class="left_box">

               <div class="avi"><img src="i/avi.jpg" alt="" /></div>

                <div class="left_box_right">

                USER: <a href="">Eon</a><br />

                RANK: Chief<br />

                <img src="i/online.jpg" alt="" />

                </div>

                REP: 98<br />

                WEBSITE: <a href="http://www.halotrilogy.org">teamvirtue.com</a>

            </div>

            <div class="right">

               <h1>..</h1>

               <h2>..</h2>

                <p>...</p>

                <p>..</p>

                <p>..</p>

                <h2>..</h2>

                <p>..</p>

                <h2>..</h2>

                <p>..</p>

            </div>

            <div class="clear"></div>

            <div class="content_foot"></div>

        </div>

    </div>

    <div class="clear"></div>

    <div id="footer">

       <div id="footer_text">Designed by <a href="http://www.briteon.net">Adam 'Eon' Reynolds</a> and Coded by <a href="http://www.dornblaser.info">Kyle 'ThePerfectCrime' Dornblaser</a></div>

       <a href="" id="top"></a>

    </div>

    <div id="footerfix">ctvirtue</div>

</div>

</body>

</html>



that right there is the whole code. any assistance would be really appreciated.
dars
 
Posts: 7
Joined: Tue Mar 09, 2010 10:40 pm
Online: 0s
Karma: 0

Re: phpBB login integration

Postby wide_load » Thu Mar 18, 2010 10:00 am

dars wrote:ok well that didnt really help. as stand alone the php script works great! however as soon as i include it in my html i get an error. its like its not fitting in right...round hole square peg type deal.

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

   <title>TLMC</title>

    <link rel="stylesheet" type="text/css" href="perfect.css" />

    <script type="text/javascript">

      <!--

      function ctRoster(usrName)

      {

         var collection = usrName;

      

         document.getElementById('roster_name').innerHTML = collection;

      }

      function ctRosterClean()

      {

         document.getElementById('roster_name').innerHTML = "Hover Above";

      }

      // -->

   </script>

</head>

<body>

<div id="container">

   <div id="banner"></div>

    <ul id="nav">

       <li><a href="index.html" id="home"><span><img src="i/home_roll.jpg" alt="" /></span></a></li>

        <li><a href="forums.html" id="forums"><span><img src="i/forums_roll.jpg" alt="" /></span></a></li>

        <li><a href="about.html" id="about"><span><img src="i/about_roll.jpg" alt="" /></span></a></li>

        <li><a href="matches.html" id="matches"><span><img src="i/matches_roll.jpg" alt="" /></span></a></li>

        <li><a href="roster.html" id="roster"><span><img src="i/roster_roll.jpg" alt="" /></span></a></li>

        <li><a href="contact.html" id="contact"><span><img src="i/contact_roll.jpg" alt="" /></span></a></li>

    </ul>

    <div id="left">

       <div id="user_area"></div>

        <div class="content">
<?php

//ob
ob_start();

//session
session_start();

if (isset($_SESSION['username']))
{
header("Location: main.php");
exit(); 
}

//connect
$error = 'Could not connect to the database';
mysql_connect('localhost','','') or die($error);
mysql_select_db('c809189_forum') or die($error);

//include functions.php phpbb script
require 'phpBB3/includes/functions.php';

if ($_POST['login'])
{
//get form data
$username = addslashes(strip_tags(strtolower($_POST['username'])));
$password = addslashes(strip_tags($_POST['password']));

if (!$username||!$password)
    echo "Please enter a username and password<p />";
else
{
  //find username
  $find = mysql_query("SELECT * FROM phpbb_users WHERE username_clean='$username'");
  if (mysql_num_rows($find)==0)
     echo "Username not found<p />";
  else
  {
   while ($find_row = mysql_fetch_assoc($find))
   {
    // grab password hash for user
    $password_hash = $find_row['user_password'];
   }
   
   $check = phpbb_check_hash($password, $password_hash);
   if ($check==FALSE)
      echo "Incorrect password<p />";
   else if ($check==TRUE)
   {
    $_SESSION['username']=$username;
    header("Location: main.php");
    exit();
   }
  }
}
}

?>

         <form action="" method="get">

               <div id="form">

                    <input type="text" value="username" class="input_box" />

                    <input type="text" value="password" class="input_box" />

                </div>

                <div id="submit">

                   <input type="submit" value="" id="go" />

                     <input type="button" value="" id="reg" />

                </div>

            </form>

            <div class="clear"></div>

        </div>

        <div id="latest_matches"></div>

        <ul>

            <li>Virtue Vs Fluffy Multi-Coloured Penguins</li>

            <li>Virtue Vs Fluffy Multi-Coloured Penguins</li>

            <li>Virtue Vs Fluffy Multi-Coloured Penguins</li>

            <li>Virtue Vs Fluffy Multi-Coloured Penguins</li>

            <li>Virtue Vs Fluffy Multi-Coloured Penguins</li>

        </ul>

        <a href="" class="archive"></a>

      <div id="quick_roster"></div>

        <div class="content">

            <a href="" onmouseover="ctRoster('Eon');" onmouseout="ctRosterClean();"><img src="i/roster1.jpg" alt="" /></a>

            <a href="" onmouseover="ctRoster('TerrorKalle');" onmouseout="ctRosterClean();"><img src="i/roster2.jpg" alt="" /></a>

            <a href="" onmouseover="ctRoster('RMLR');" onmouseout="ctRosterClean();"><img src="i/roster3.jpg" alt="" /></a>

            <a href="" onmouseover="ctRoster('ThePerfectCrime');" onmouseout="ctRosterClean();"><img src="i/roster4.jpg" alt="" /></a>

            <a href="" onmouseover="ctRoster('Andrei');" onmouseout="ctRosterClean();"><img src="i/roster5.jpg" alt="" /></a>

            <a href="" onmouseover="ctRoster('serenity');" onmouseout="ctRosterClean();"><img src="i/roster6.jpg" alt="" /></a>

            <div id="roster_name">Hover Above</div>   

            <a href="" class="archive"></a>     

        </div>

        <div id="our_sponsors"></div>

        <a href="http://www.clantemplates.com" id="ct"></a>

        <a href="http://www.briteon.net/" id="be"></a>

        <a href="http://www.dornblaser.info" id="dornblaser"></a>

    </div>

    <div id="right">

       <div class="content_top"></div>

        <div class="right_content">

           <div class="left_box">

               <div class="avi"><img src="i/avi.jpg" alt="" /></div>

                <div class="left_box_right">

                USER: <a href="">Eon</a><br />

                RANK: Chief<br />

                <img src="i/online.jpg" alt="" />

                </div>

                REP: 98<br />

                WEBSITE: <a href="http://www.halotrilogy.org">teamvirtue.com</a>

            </div>

            <div class="right">

               <h1>..</h1>

                <p>..</p>



                <p>..</p>

               

                <p>..</p>



               

               

                <p>:</p>

               

                <p>..</p>
                <p>..</p>

               

                <p>..</p>

            </div>

            <div class="clear"></div>

            <div class="content_foot"></div>

        </div>

       <div class="content_top"></div>

        <div class="right_content">

           <div class="left_box">

               <div class="avi"><img src="i/avi.jpg" alt="" /></div>

                <div class="left_box_right">

                USER: <a href="">Eon</a><br />

                RANK: Chief<br />

                <img src="i/online.jpg" alt="" />

                </div>

                REP: 98<br />

                WEBSITE: <a href="http://www.halotrilogy.org">teamvirtue.com</a>

            </div>

            <div class="right">

               <h1>..</h1>

               <h2>..</h2>

                <p>...</p>

                <p>..</p>

                <p>..</p>

                <h2>..</h2>

                <p>..</p>

                <h2>..</h2>

                <p>..</p>

            </div>

            <div class="clear"></div>

            <div class="content_foot"></div>

        </div>

    </div>

    <div class="clear"></div>

    <div id="footer">

       <div id="footer_text">Designed by <a href="http://www.briteon.net">Adam 'Eon' Reynolds</a> and Coded by <a href="http://www.dornblaser.info">Kyle 'ThePerfectCrime' Dornblaser</a></div>

       <a href="" id="top"></a>

    </div>

    <div id="footerfix">ctvirtue</div>

</div>

</body>

</html>



that right there is the whole code. any assistance would be really appreciated.



does the file have the .php extension ?
Image
User avatar
wide_load
Top Contributor
 
Posts: 5616
Joined: Thu Aug 13, 2009 1:04 pm
Online: 13d 21h 56m 33s
Karma: 45

Re: phpBB login integration

Postby dars » Thu Mar 18, 2010 2:50 pm

no it does not. its a html file, but my understanding is that php code can be used inside html code.
dars
 
Posts: 7
Joined: Tue Mar 09, 2010 10:40 pm
Online: 0s
Karma: 0

Re: phpBB login integration

Postby wide_load » Thu Mar 18, 2010 3:46 pm

dars wrote:no it does not. its a html file, but my understanding is that php code can be used inside html code.


but it has to be a .php file for that to work

the apache module only sends .php files to the php binary for processing.
Image
User avatar
wide_load
Top Contributor
 
Posts: 5616
Joined: Thu Aug 13, 2009 1:04 pm
Online: 13d 21h 56m 33s
Karma: 45

Re: phpBB login integration

Postby dars » Thu Mar 18, 2010 3:50 pm

so how would i use this to log in from my home page? obviously my home page is html/css. i cant use html in a .php file...it shows up blank
dars
 
Posts: 7
Joined: Tue Mar 09, 2010 10:40 pm
Online: 0s
Karma: 0

Re: phpBB login integration

Postby wide_load » Thu Mar 18, 2010 3:52 pm

dars wrote:so how would i use this to log in from my home page? obviously my home page is html/css. i cant use html in a .php file...it shows up blank


yes you can as long as its outside of the <?php and ?> tags
Image
User avatar
wide_load
Top Contributor
 
Posts: 5616
Joined: Thu Aug 13, 2009 1:04 pm
Online: 13d 21h 56m 33s
Karma: 45

Next

Return to Tutorial Help

Who's online?

Users browsing this forum: No registered users and 1 guest