PHP登录脚本不起作用?

时间:2013-05-27 15:59:05

标签: php mysql html5 function login-script

嗨我无法让我的phpbb论坛登录脚本工作,如果($_POST['login']),我刚发布的行是一些怎么不工作?老实说,我不知道为什么,但我真的需要这个为我的主站点,你们可以帮助吗? 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>

1 个答案:

答案 0 :(得分:0)

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

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

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

来自W3Schools:
除非失败,否则包括和要求是相同的

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

干杯