-1

Hi i can't get my phpbb forum login script to work, if ($_POST['login']) , the line i just posted is some how not working? I honestly don't know why but I really need this for my main site can you guys help? www.zaoby.co.uk

<?php

//ob
ob_start();

//session
session_start();

//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 ($_POST['login']) "THIS PART IS COMING UP IN A ERROR BOX" 
{
 //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>
4

1 回答 1

0

有时是之前的规则实际上导致了错误。
require '../forums/includes/functions.php';

我假设您使用 functions.php 来使用它: phpbb_check_hash(); ?

如果它不加载functions.php,它将完全停止,因为您正在使用require,并且不会显示任何类似错误密码的回显,因为即使$check 为false,脚本也会停止。您可以尝试将 ../ 放在您的路径之前,您可以尝试使用 include 来查看它是否有所作为。

来自 W3Schools:
Include 和 require 是相同的,除非失败

  • require 将产生一个致命错误(E_COMPILE_ERROR)并停止脚本
  • include 只会产生警告(E_WARNING)并且脚本将继续

干杯

于 2013-05-28T02:06:39.763 回答