2016-04-08 88 views
0

我正在按照創建註冊和登錄系統的教程。我盡一切努力,但當我按下提交表單時,仍然出現奇怪的嚴格標準錯誤。嚴格的標準錯誤,同時保存註冊數據

<?php 

require 'pdoconnect.php'; 

$message = ''; 

if(!empty($_POST['email']) && !empty($_POST['password'])): 


// Enter the new user in the database 
$sql = "INSERT INTO users (email, password) VALUES (:email, :password)"; 
$stmt = $conn->prepare($sql); 

$stmt->bindParam(':email', $_POST['email']); 
$stmt->bindParam(':password', password_hash($_POST['password'], PASSWORD_BCRYPT)); 

if($stmt->execute()): 
    $message = 'Successfully created new user'; 
else: 
    $message = 'Sorry there must have been an issue creating your account'; 
endif; 

endif; 

?> 

它說

嚴格的標準:只有變量應該通過線14(與密碼哈希線)引用傳遞。

我已經找遍瞭解決方案,但我無法找到任何。

+0

在使用'bindParam()'中的散列值之前,您應該對密碼*進行散列* –

回答

1

散列你將它綁定之前的密碼

// Enter the new user in the database 
$sql = "INSERT INTO users (email, password) VALUES (:email, :password)"; 
$stmt = $conn->prepare($sql); 

$hashedPass = password_hash($_POST['password'], PASSWORD_BCRYPT); 
$stmt->bindParam(':email', $_POST['email']); 
$stmt->bindParam(':password', $hashedPass); 

你不能傳遞一個函數到綁定參數,你只能傳遞一個變量。

+1

謝謝!密碼現在已經在數據庫中安全散列:) – SmashingJummy

+1

很好......看看你先生的花式褲。現在我們將不得不打電話給你先生「熱」褲薩姆。 –

+1

*我gotcho'熱褲權hea'拉爾夫!* @ Fred-ii- –