PHP + Ajax Login
$user = new User(array("username" => $_POST['username'], "password" => $_POST['password']));
$user->Login();
Put the code above into an login.php controller file (including your users class). Or write a general controller that handles the requests.
whole issue is in jquery use this instead
$(document).ready(function() {
$('#loginform').submit(function(e) {
e.preventDefault();
$.ajax({
type: "POST",
url: '/class/login.php',
data: $(this).serialize(),
success: function(data)
{
if (data === 'Login') {
window.location = '/user-page.php';
}
else {
alert('Invalid Credentials');
}
}
});
});
});