Domanda

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>
È stato utile?

Soluzione

Sometimes it's the rule before that actually causes the error.
require '../forums/includes/functions.php';

I assume you use functions.php to use this: phpbb_check_hash(); ?

If it doesn't load functions.php it will stop completely because you are using require and won't show any echo's of like incorrect password because even if $check were to be false the script stops. You can try and put ../before your path, and you can try to use include to see if it makes a difference.

From W3Schools:
Include and require are identical, except upon failure

  • require will produce a fatal error (E_COMPILE_ERROR) and stop the script
  • include will only produce a warning (E_WARNING) and the script will continue

Cheers

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top