Good day, I'm trying to make a login screen in php & mysql with Jquery(ajax). but I'm having a problem with if else statement.
Here's my code.
$("#btnLogin").click(function(){
username=$("#textUsername").val();
password=$("#textPassword").val();
$.ajax({
type: "POST",
url: "login.php",
data: "username="+username+"&password="+password,
success: function(result){
var res = result;
if(res == 'correct'){
alert("success login");
} else {
console.log("fail login");
}
}
});
return false;
});
it always fall in else. even the result is return as correct