Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8616055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:31:42+00:00 2026-06-12T05:31:42+00:00

I want to working with login system jQuery ajax and json. I’m facing no

  • 0

I want to working with login system jQuery ajax and json. I’m facing no problem with success function. I dn’t know how to through custom errors like “incorrect login”.

Here is my code, Please help me.

<script>
    $(document).ready(function(){
        $("#login").click(function(){
            if($("#defaultEmail").val() == ""){
                $("#defaultEmail").addClass("field-err");
                $("#defaultEmail").focus();
            }else if($("#defaultPassword").val() == ""){
                $("#defaultEmail").removeClass("field-err");
                $("#defaultPassword").addClass("field-err");
                $("#defaultPassword").focus();
            }else{
                $("#defaultPassword").removeClass("field-err");
                $('#loading').css('display', 'block');
                var email = $('#defaultEmail').val();
                var password = $('#defaultPassword').val();
                var queryString = "email=" + email + "&password=" + password + "";
                $.ajax({
                  url: 'secureLogin.php',
                  contentType: "application/json; charset=utf-8",
                  dataType:'json',
                  async: false,
                  type:'GET',
                  data: queryString,
                  success: function(data){
                    $('#loading').css('display', 'none');
                    var url = "c_profile.php";
                    $(location).attr('href',url);
                  },
                  error: function(request,error){
                    $('#loading').css('display', 'block');
                    $("#log-ajax-error").append("ERROR: " + error);
                  }
                });
            }
        });
    });
</script>

Here is my sucureLogin.php code

$email = $_GET['email'];
$password = $_GET['password'];
$encrypted_pass = md5($password);

    $sel = @mysql_query("SELECT `name`, `company`, `cid` FROM `company` WHERE `email` = '$email' AND `password` = '$encrypted_pass'");
    $count = @mysql_num_rows($sel);
    if($count > 0){
        while($data = @mysql_fetch_array($sel)){
                       // Success here
        }
    }else{
        $arr = array('a' => 'Unable to login');
        echo json_encode($arr);
    }

i’m throwing json_encode for the error. Please help me with this. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:31:43+00:00Added an answer on June 12, 2026 at 5:31 am

    On the server side

    $arr = array('error' => 'Unable to login');
    echo json_encode($arr);
    

    On the client side

    success: function(data){
        $('#loading').hide(); 
        if( 'error' in data ){ 
            $("#log-ajax-error").append("ERROR: " + data.error);
        }
        else{
           var url = "c_profile.php";
           $(location).attr('href',url);
        }
    },
    

    The error callback will be called if there’s an error with the ajax request, so your code needs to be in the success handler.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very wierd problem. I created a login system with ajax and
I'm working on an AJAX login system. Right now, when the user clicks on
I'm working on a login page, I want the user to see his name
I'm working in PHP and I want to create a function that, given a
I have a working FTP system with android, but I want to be able
I'm really struggling to make facebook connection working for my system. What I want
Working on a login system - the point where customer chooses their password for
I want to create a login system with a MS Access database. the data
I am struggling to get my LogIn/Registering system working. I have a register.aspx page
I am working android application that required login, Now I want After successfully login

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.