Hi,
I’m creating a login form and what I am trying to do is that when the form was successfull, it will hide. If there were errors, it should not hide.
login_proc.php
“`
if(mysqli_num_rows($result) > 0) { // When this if statement is getting called, it should hide a certain div
$class = “success”;
$title = “Success!”;
$msg = “Correct Password!”;
} else {
$class = “danger”;
$title = “Error!”;
$msg = “Incorrect Password!”;
}
I can use this to hide the form but I have no idea how to achieve what Im trying: login-form.style.display = “none”;
This is my jquery/ajax code:
“`
$(‘.btn-login’).click(function (e) {
e.preventDefault();
var mail = $(‘#mail’).val();
var password = $(‘#password’).val();
loader.style.display = “block”;
setTimeout(function() {
$.ajax
({
type: “POST”,
url: “bin/login_proc.php”,
data: { “mail”: mail, “password”: password },
success: function (data) {
$(‘.result’).html(data);
$(‘#logform’)[0].reset();
loader.style.display = “none”;
// If login was succesful, hide the div… But how?
}
});
}, 1000);
});
Any help would be appreciated