Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function logInAjax(){
- var username = document.getElementById('login_username').value;
- var password = document.getElementById('login_password').value;
- var login = "username=" + username + "&password=" + password;
- var usernameCheck = 0;
- var passwordCheck = 0;
- if (username == "") {
- $("#error").html("" +
- "<div class='alert alert-warning alert-dismissible' role='alert'> " +
- "<button type='button' class='close' data-dismiss='alert' aria-label='Close'>" +
- "<p class='zmdi zmdi-close'</p>" +
- "</button>" +
- "<strong>" +
- "<i class='zmdi zmdi-alert-triangle'></i> Warning!" +
- "</strong>" +
- " Username cannot be Blank!" +
- "</div>");
- ("login");
- } else {
- usernameCheck = 1;
- }
- if (password == "") {
- $("#error").html("" +
- "<div class='alert alert-warning alert-dismissible' role='alert'> " +
- "<button type='button' class='close' data-dismiss='alert' aria-label='Close'>" +
- "<p class='zmdi zmdi-close'</p>" +
- "</button>" +
- "<strong>" +
- "<i class='zmdi zmdi-alert-triangle'></i> Warning!" +
- "</strong>" +
- " Password cannot be blank." +
- "</div>");
- ("login");
- } else {
- passwordCheck = 1;
- }
- if(usernameCheck == 1 && passwordCheck == 1){
- $.ajax({
- type: "POST",
- url: "userLogin.php",
- data: login,
- success: function(html){
- console.log(html);
- if(html == "Success"){
- $("#error").html("<div class='alert alert-success alert-dismissible' role='alert'> " +
- "<button type='button' class='close'>" +
- "<p class='zmdi zmdi-close'</p>" +
- "</button>" +
- "<strong>" +
- "<i class='zmdi zmdi-alert-triangle'></i> Success!" +
- "</strong>" +
- "Redirecting..." +
- "</div>"
- );
- setTimeout(function() {
- window.location = "./index.php";
- }, 2000);
- } else {
- $("#error").html("" +
- "<div class='alert alert-warning alert-dismissible' role='alert'> " +
- "<button type='button' class='close'>" +
- "<p class='zmdi zmdi-close'</p>" +
- "</button>" +
- "<strong>" +
- "<i class='zmdi zmdi-alert-triangle'></i> Warning!" +
- "</strong>" +
- "<br>" +
- "Incorrect username and password." +
- "</br>" +
- "</div>"
- );
- };
- },
- beforeSend:function(){
- $("#error").html("Logging In");
- }
- });
- return false;
- } else {
- $("#error").html("" +
- "<div class='alert alert-warning alert-dismissible' role='alert'> " +
- "<button type='button' class='close' data-dismiss='alert' aria-label='Close'>" +
- "<p class='zmdi zmdi-close'</p>" +
- "</button>" +
- "<strong>" +
- "<i class='zmdi zmdi-alert-triangle'></i> Warning!" +
- "</strong>" +
- "Please fill out the necessary information." +
- "</div>");
- ("login");
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement