SeattleMicah
07-15-2012, 09: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?
login.php
if(isset($_POST['submit'])) {
$username = trim($_POST['username']);
$password = trim($_POST['password']);
$found_user = User::authenticate($username, $password);
if($found_user) {
$session->login($found_user);
redirect_to("index.php");
} 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;
}
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?
login.php
if(isset($_POST['submit'])) {
$username = trim($_POST['username']);
$password = trim($_POST['password']);
$found_user = User::authenticate($username, $password);
if($found_user) {
$session->login($found_user);
redirect_to("index.php");
} 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;
}