I am working on a login system for a project using MVC programming and ran into this error. Here is the code, the problem line is #31
This login system is a tutorial, I have been working through it exactly as is. I've read there are some version issues with PHP 5? Not sure, hopefully somebody could assist me.
Problem line:
$stmt->bind_param("ss", $user, md5($pass . $this->salt));
Code:
<?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();
}
}