The return data for this one as I investigated is "authenticated" which means the if statement should take effect. However, to reasons I know not it goes directly to the else part of the statement making the data false even if it's true. Like "authenticated"=="authenticated"
. It ignores the if part and I don't know why.
function login_admin_user() {
username = $("#ad-username").val();
password = $("#ad-password").val();
$("#button-login").val("Logging in...");
$.post("ajax-login.php", {
username: username,
password: password
}, function (data) {
if (data == "authenticated") {
/* Execute if authenticated */
$("#box-login-confirmed").fadeIn("slow", function () {
$("#button-login").val("Login");
})
.delay(1000)
.fadeOut(400, function () {
window.location = "home.php";
});
} else {
/* Execute if invalid login */
$("#box-login-error").fadeIn("slow", function () {
$("#button-login").val("Login");
$("#ad-password").val("");
})
.delay(3000)
.fadeOut(400);
}
});
}