Created
February 10, 2017 19:45
-
-
Save KOUISAmine/f3aa9a95de891ef903a96206d7158239 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
$error = $('<center><label style = "color:#ff0000;">Nom d\'utilisateur ou mot de passe incorrect</label></center>'); | |
$error2 = $('<center><label style = "color:#ff0000;">Utilisateur n\' existe pas!</label></center>'); | |
$success = $('<center><label style = "color:#00ff00;">Connexion réussie!</label></center>'); | |
$loading = $('<center><img src = "loading.gif" height = "5px" width = "100%"/></center>'); | |
$('#login').on('click', function(){ | |
$error.remove(); | |
$error2.remove(); | |
$username = $('#username').val(); | |
$password = $('#password').val(); | |
if($username == "" && $password == ""){ | |
$error.appendTo('#result'); | |
}else{ | |
$loading.appendTo('#result'); | |
setTimeout(function(){ | |
$loading.remove(); | |
$.post('validator.php', {username: $username, password: $password}, | |
function(result){ | |
if(result == "Success"){ | |
$('#username').val(''); | |
$('#password').val(''); | |
$success.appendTo('#result'); | |
setTimeout(function(){ | |
$success.remove(); | |
window.location = 'home.php'; | |
}, 1000); | |
}else{ | |
$('#username').val(''); | |
$('#password').val(''); | |
$error2.appendTo('#result'); | |
} | |
} | |
) | |
}, 3000); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment