szucsy11
10-14-2012, 08:42 PM
Hello guys.
My problem is that everything works just fine, but i cant log in. When i try to log in with a correct username and password and the account IS activated it still says "Array ( [0] => Activate your account ) "
This is the function:
function user_active($username) {
$username = sanitize($username);
return(mysql_result(mysql_query("SELECT COUNT(user_id) FROM users WHERE `username` = '$username' AND 'active' = '1'"), 0) == 1 ) ? true : false;
}
And this is the code/session from login.php ( i copied the whole thing) :
<?php
include 'core/init.php';
if (empty($_POST) === false) {
$username = $_POST['username'];
$password = $_POST['password'];
if (empty($username) === true || empty ($password) === true) {
$errors [] = 'You need to enter a username and password';
} else if (user_exists($username) === false) {
$errors [] = 'We can\'t find that username. Have you registered?';
} else if (user_active($username) === false) {
$errors [] = 'Activate your account';
} else {
$login= login($username, $password);
if ($login === false) {
$errors [] = 'That username/pasword combination is incorrect';
} else {
$_SESSION['user_id'] = $login;
header('Location: index.php');
exit();
}
}
print_r($errors);
}
?>
Thank you.
My problem is that everything works just fine, but i cant log in. When i try to log in with a correct username and password and the account IS activated it still says "Array ( [0] => Activate your account ) "
This is the function:
function user_active($username) {
$username = sanitize($username);
return(mysql_result(mysql_query("SELECT COUNT(user_id) FROM users WHERE `username` = '$username' AND 'active' = '1'"), 0) == 1 ) ? true : false;
}
And this is the code/session from login.php ( i copied the whole thing) :
<?php
include 'core/init.php';
if (empty($_POST) === false) {
$username = $_POST['username'];
$password = $_POST['password'];
if (empty($username) === true || empty ($password) === true) {
$errors [] = 'You need to enter a username and password';
} else if (user_exists($username) === false) {
$errors [] = 'We can\'t find that username. Have you registered?';
} else if (user_active($username) === false) {
$errors [] = 'Activate your account';
} else {
$login= login($username, $password);
if ($login === false) {
$errors [] = 'That username/pasword combination is incorrect';
} else {
$_SESSION['user_id'] = $login;
header('Location: index.php');
exit();
}
}
print_r($errors);
}
?>
Thank you.