$salt = md5(mt_rand());
$hashed = hash_hmac('SHA256', $password, $salt);
$stmt = self::$_dbh->prepare('INSERT INTO users (username, password, salt, display, email) VALUES (:username, :password, :salt, :display, :email)');
$stmt->bindParam('username', $username);
$stmt->bindParam('password', $hashed);
$stmt->bindParam('salt', $salt);
$stmt->bindParam('display', $display);
$stmt->bindParam('email', $email);
$stmt->execute();
$firephp->log('Insert OK ');
if ($stmt->rowCount() > 0) {
return array(
'status' => 'OK',
'message' => 'Registration Successful'
);
}
$firephp->log('Unknown ... Row count: ' . $stmt->rowCount());
return array(
'status' => 'failed',
'message' => 'Something went wrong with the registration ... Please try again ...'
);
我總是得到「出了毛病,註冊...請再試一次...」。看起來rowCount
是0.真的夠了,它不會插入到數據庫中。這是爲什麼?
我錯過了'else'。最後的'$ firephp-> log'調用始終(無條件地)執行。沒關係,誤解它。 – 2011-06-03 10:35:56