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 7027227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:13:13+00:00 2026-05-28T00:13:13+00:00

I am stuck with ajax response, that always go in else part and it

  • 0

I am stuck with ajax response, that always go in else part and it print no in session’s class called statusmsg and also add meta tag.
It is fine in localhost but not in live site.

Output:

<div class="statusmsg">
Welcome
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Untitled Document</title>
no
</div>

Here is my login code with ajax jquery

      $.ajax({             
                    type: "POST",  
                    url:"scripts/ajax_login.php",  
                    data:"account="+account+"&pswd="+password,

                    beforeSend: function()
                    {
                        $(".login_result").show();
                    },
                    success: function(resp)
                    {  

                        if($.trim(resp) == 'no')
                        {   
                            $(".warn_msg").html("Wrong Username/Email And/or Passwrd");
                            return false;                               
                        }
                        else
                        {   
                            $(".statusmsg").html("Welcome "+$.trim(resp));
                            $(".loginArea").hide();
                            $(".sh_logout").show();                                                     
                        }
                    }, 

                    complete: function()
                    {
                        $(".login_result").hide();
                    },

                    error: function(e)
                    {  
                    alert('Error: ' + e);  
                    }  

               }); //end Ajax   

                   }//else   
              return true;
               }//function

=========================================
ajax_login.php

session_start();

include(dirname(dirname(__FILE__))."/includes/config.php");

$account  = mysql_real_escape_string($_POST['account']);
$password = mysql_real_escape_string(md5($_POST['pswd']));

$sql = (strpos($account,'@')===false)?"SELECT * FROM register_members WHERE username = '".$account."' AND password = '".$password."'":"SELECT * FROM register_members WHERE password = '".$password."' AND email = '".$account."' ";

$qry = mysql_query($sql);
$msg = mysql_num_rows($qry); //returns 0 if not already exist
$row = mysql_fetch_assoc($qry);


if(!$msg > 0)
{   
    echo trim('no');
}
else
{
$_SESSION['user'] = $row['username'];       
$user = trim($_SESSION['user']);
echo trim($user);   
}
  • 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-05-28T00:13:14+00:00Added an answer on May 28, 2026 at 12:13 am
    if(!$msg > 0)
    {   
        echo trim('no');
    }
    

    Should be

    if !($msg > 0)
    {   
        echo trim('no');
    }
    

    Else you are negating the value in $msg. If this is 0 it becomes 1 and if it’s 1 it becomes 0. (Basic negation of a boolean value).

    So neither 1 nor 0 will ever be bigger than 0 and thus it will never echo trim('no');.

    But basically you can just check if $msg equals to zero like:

    if ($msg == 0) {
       echo trim('no');
    }
    else {
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an jquery ajax application.. where i got stuck And i uploaded
My PHP backend sends XML response to the client (ajax): <response> <code>0</code> <message>OK</message> </response>
I need to wait for an ajax response inside a for loop. If I
I have an Ajax control that is loaded into a Yahoo popup using jQuery.
I am trying to create an html form that uses AJAX to load database
Edit This is the function where I get the response from $(document).ready(function() { $.ajax({
I decided to dive into AJAX with help of jQuery, and I'm stuck already...
Is it possible to make such a HTTP response, that the browser ignores it
I have an ajax call to a php file that encodes the array into
I have this script that I found which allows me to have userside Ajax

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.