2016-01-08 31 views
-1

我有一個形式與phpcaptcha.org。但是,當我提交表單時,我看到一個白色屏幕,驗證碼腳本不起作用,其他代碼工作。 有人可以幫助我什麼是錯誤的驗證碼?php captcha.org不起作用

在此先感謝。

我提交的代碼是:

<?php 
session_start(); 

//captcha 
include_once $_SERVER['DOCUMENT_ROOT'] . 'securimage/securimage.php'; 
$securimage = new Securimage(); 


include 'connect.php'; 


$sql = "INSERT INTO users (username, password)VALUES (?, ?)"; 
$stmt = $link->prepare($sql); 
$stmt->bind_param("ss", $username, $password); 


$username = $_POST['username']; 

$password = md5($_POST['password']); 

$stmt->execute(); 


//captcha 
if ($securimage->check($_POST['captcha_code']) == false) { 
    // the code was incorrect 
    // you should handle the error so that the form processor doesn't continue 

    // or you can use the following code if there is no validation or you do not know how 
    echo "The security code entered was incorrect.<br /><br />"; 
    echo "Please go <a href='javascript:history.go(-1)'>back</a> and try again."; 
    exit; 
} 

if (! $sql) { 
    echo "Account not created"; 
} 
    echo 'Account created, click <a href="index.php">here</a>'; 

$stmt->close(); 
mysqli_close($link); 

?> 
+1

ini_set('display_errors',1); ini_set('display_startup_errors',1); error_reporting(E_ALL); 併發布錯誤。 –

+0

錯誤是:警告:include_once(C:/xampp/htdocssecurimage/securimage.php):未能打開流:第12行的C:\ xampp \ htdocs \ folder \ register.php中沒有這樣的文件或目錄 警告:include_once():無法在C:\ xampp \ htdocs \ folder \ register.php中打開包含(include_path ='.; C:\ xampp \ php \ PEAR')的'C:/xampp/htdocssecurimage/securimage.php' on line 12 致命錯誤:在第13行的C:\ xampp \ htdocs \ folder \ register.php中找不到類'Securimage' – maichel

+1

閱讀錯誤消息,然後閱讀第5行。您缺少目錄分隔符。將第5行更改爲'include_once $ _SERVER ['DOCUMENT_ROOT']。 「/ securimage/securimage.php'' –

回答

2

我覺得的主要問題隱藏在include_once $_SERVER['DOCUMENT_ROOT'] . 'securimage/securimage.php';線。你有沒有試過在securimage/securimage.php之前把另一個斜槓(/)?它看起來像PHP試圖包含指定的文件,由於缺少斜槓無法找到它,繼續其餘的代碼,並且不能創建新的Securimage變量,因爲類型未定義。如果將include_once()更改爲require_once(),則可能會出現錯誤。

在另一方面,我會強烈建議使用更強的哈希算法比MD5 ,這是安全方面非常薄弱。請考慮使用內置的crypt函數的PHP與更好的算法,如BLOWFISHSHA-512。如果你有超過PHP 5.5以上的版本,你可能還會發現另一種內置的PHP函數,稱爲password_hash非常有用。希望這有幫助。