2013-05-27 98 views
-1

嗨,我不能讓我的phpBB論壇登錄腳本工作,如果($_POST['login']),我剛剛張貼的線路是一些如何不工作?我真的不知道爲什麼,但我真的需要這個爲我的主站點可以幫助你嗎? www.zaoby.co.ukPHP登錄腳本不起作用?

<?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> 
+2

你沒有關閉' andrewsi

+0

檢查,如果你是'$ _ SERVER [ 'REQUEST_METHOD'] === 「POST」'發佈。 –

+0

是什麼意思它不工作?你有一個白頁?您提交但保持未記錄?請解釋一下自己,否則我們無法幫忙。但首先,關閉您的代碼,如第一個註釋說明應該解決一些問題... – ffarquet

回答

0

有時這是規則之前,實際上導致錯誤。
require '../forums/includes/functions.php';

我假設你使用functions.php來使用這個:phpbb_check_hash(); ?

如果沒有加載的functions.php就會完全停止,因爲你使用的需要,並不會出現像密碼不正確,因爲即使$檢查均是假的腳本停止任何迴音的。你可以試試,把你的../before路徑,你可以嘗試使用包括,看它是否有差別。

從W3Schools的:
包括和要求是相同的,只是在出現故障時

  • 要求會產生一個致命錯誤(E_COMPILE_ERROR)和停止腳本
  • 包括只會產生一個警告(E_WARNING)和該腳本將繼續

乾杯