View Full Version : login issue

07-15-2012, 10:52 PM
been trying to debug for too long now, need to ask for some help.

it all functions properly, except when I type in the verified correct login name and password. When I type in the correct info the redirect does not function, login.php is reloaded with a blank form and no errors?


if(isset($_POST['submit'])) {

$username = trim($_POST['username']);
$password = trim($_POST['password']);

$found_user = User::authenticate($username, $password);

if($found_user) {
} else {
$message = "Username/password combination incorrect.";
} else {
$username = "";
$password = "";

apart of my User class

public static function authenticate($username="", $password="") {
global $database;
$username = $database->escape_value($username);
$password = $database->escape_value($password);

$sql = "SELECT * FROM users ";
$sql .= "WHERE username = '{$username}' ";
$sql .= "AND password = '{$password}' ";
$sql .= "LIMIT 1";
$result_array = self::find_by_sql($sql);
return !empty($result_array) ? array_shift($result_array) : false;


07-16-2012, 01:00 AM
I don't have any way of testing my theory right now, but I think it could be the last major line in the second piece of code.

return !empty($result_array) ? array_shift($result_array) : false;

This tells the script if the $result_array is not empty then return false.

I would assume if the result returns as not empty then it would want to return true.

Just a guess.

07-17-2012, 07:27 AM
I dont believe that is the issue.

if the
!empty($result_array) which it is not empty, then

I tested something via

public static function find_by_id($id=0) {
global $database;
$result_array = self::find_by_sql("SELECT * FROM users WHERE id={$id} LIMIT 1");
return !empty($result_array) ? array_shift($result_array) : false;

$user = User::find_by_id(1);
echo $user->full_name();

and it returns the correct info