我正在使用MVC编程项目的登录系统,并遇到此错误。这里是代码,问题行是#31严格的标准:只有变量应通过引用传递m_auth
这个登录系统是一个教程,我一直在按照原样进行。我读过PHP 5有一些版本问题?不知道,希望有人能帮助我。
问题行:
$stmt->bind_param("ss", $user, md5($pass . $this->salt));
代码:
<?php
/*
Authorization Class
deal with auth tasks
*/
class Auth
{
private $salt = 'j4H9?s0d';
/*
Constructor
*/
function __construct()
{
}
/*
Functions
*/
function validateLogin($user, $pass)
{
// access db
global $Database;
// create query
if ($stmt = $Database->prepare("SELECT * FROM users WHERE username = ? AND password = ?"))
{
$stmt->bind_param("ss", $user, md5($pass . $this->salt));
$stmt->execute;
$stmt->store_result();
// check for num rows
if ($stmt->num_rows > 0)
{
// success
$stmt->close();
return TRUE;
}
else
{
// failure
$stmt->close();
return FALSE;
}
}
else
{
die("ERROR: Could not prepare MySQLi statement.");
}
}
function checkLoginStatus()
{
if (isset($_SESSION['loggedin']))
{
return TRUE;
}
else
{
return FALSE;
}
}
function logout()
{
session_destroy();
session_start();
}
}
[严格标准:只有变量应通过引用传递]的可能重复(http://stackoverflow.com/questions/2354609/strict-standards-only-variables-should-be-passed-by-reference) – Oswald
请勿将MD5用于哈希密码。对于PHP 5.5+,[密码API](http://uk.php.net/manual/en/book.password.php),如果这不是一个选项,你可以使用'crypt()'与blowfish算法作为一个后备。另外,**不要使用全局变量**来传播数据库连接。相反,你应该使用这样的东西:http://stackoverflow.com/a/11369679/727208(可以很容易地加入与MySQLi协同工作)。如果你的代码来自一些教程 - 尽快找到一个不同的教程。 –