Small Quick Issue

Discussion in 'jQuery' started by adamjblakey, Jun 20, 2012.

  1. #1
    Hi,

    I have the following which should be working fine and when the correct details are entered the variable for cek does return a 1 and when not returns a 0 however it should redirect when 1 is returned but doesn't, it just says login incorrect all the time.

    
    $(document).ready(function()
     {
     
     $('#logins').click(function()
     {
     var iduser = $('#email_address').val();
     var pass = $('#password').val();
    
     $("#status").html('<img src="images/loader.gif" />Logging In...');
     $.ajax({
     type: "POST",
     url: "index.php?action=login&",
     data: "email_address="+ iduser +"&password=" + pass,
     	success: function(cek){
    
    			if(cek == 1)
    			{
    			//if user is available! set user session here
    			window.location.href = 'members.php';
    			}
    			else
    			{
    			// user not available
    			$("#status").hide();
    			$("#status").fadeIn(300).html('<font color="red">Login Incorrect</font>');
    			return false;
    			}
     
    	}
    });
     
     
    return false;
    });
    });
    
    PHP:

     
    adamjblakey, Jun 20, 2012 IP
  2. wab

    wab Member

    Messages:
    57
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #2
    Are you sure cek is an integer?
    I didn't try it, but maybe you could try parseInt(cek) == 1, of cek == "1"
     
    wab, Jun 21, 2012 IP