我一直在我的网站上工作,遇到了一些问题。我按照本教程:http ://www.youtube.com/watch?v=Jq4csat4jNU&list=FLqRayDXYkEpNeTDbfJ5oBmw&index= 2 将登录从 phpbb(和用户数据库)集成到我的网站主页。唯一的问题是,当您在主页登录表单上登录后进入论坛时,它会要求您重新登录。有没有办法让它从原始的致敬登录表单登录到论坛?非常感谢,乔希
这是我的主页登录表单代码:
<div class="login_box">
<li>
<?php
//ob
ob_start();
//session
session_start();
//connect
$error = 'Could not connect to the databse';
mysql_connect('localhost','root','') or die($error);
mysql_select_db('phpbb') or die ($error);
//include functions.php phpbb script
require '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 valid username and password<p /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";
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: index.php");
exit();
}
}
}
}
if (!isset($_SESSION['username']))
{
?>
<div class="logged_out">
<form action="login.php" method="post">
<input type="text" placeholder="username" maxlength="20" size="16px" name="username" />
<input type="password" placeholder="password" maxlength="50" size="15px" name="password" />
<div class="button"><input type="image" name="login" value="Log in" src="images/login.png" width="26px" onmouseout="this.src='images/login.png'" onmouseover="this.src='images/loginhover.png'" onmouseout="t"></div>
</form>
<a href="register.php">New member? Register now</a>
</div>
<?php
}
else
{
echo "<div class='logged_in'>";
echo
"<div class='welcome'><b>".$_SESSION['username'].".</b></div>"
."<div class='account'><a href=\"userinfo.php?user=$session->username\">Messages</a></div> "
."<div class='account'><a href=\"useredit.php\">My Account</a></div> ";
echo "<div class='account'><a href=\"logout.php\">Logout</a></div>";
echo "</div>";
}
?>
</li>
</div>