简体   繁体   中英

PHPBB login script

after playing around with the script from all the help you people have given me I have come over another problem, when i click login on the login form it says: The page isn't redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete. Now i do admit i am no script pro but this is the only script i can find on how to use a phpbb forum database on a external site. so my question is whats wrong with all the .php file i am about to show you and how can i repair them?

login.php

<?php

//ob
ob_start();

//session
session_start();

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

//connect
$error = 'Zaoby Database ERROR! connection failture!';
mysql_connect('localhost','root','') or die ($error);
mysql_select_db('phpbbtest') or die($error);

//include functions.php php script
require 'forums/includes/functions.php';

if (isset($_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="login.php" method="POST">
Username:<br />
<input type="text" name="username"><p />
Password:<br />
<input type="password" name="password"><p />
<input type="submit" name="login" value="Log in">
</form>

main.php

<?php

//ob
ob_start();

//session
session_start();

$session_username = $_SESSION['username'];

if (!isset($_session_username))
{
 header("Location: login.php");
exit();
}
else
{
echo "hello, ".$_session_username." <a href='logout.php'>Log out</a>";
}
ob_end_flush();
?>

logout.php

<?php

session_start();
session_destroy();

header("Location: login.php")

?>

PS someone in my last question about this put something about using MySQLi instead of mysql_query and that i should put a ob_end_flush somewhere?

Try to use ob_start(); just after the

eg <?php ob_start();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM