Welcome Guest, Not a member yet? Register   Sign In
Problem whit redirect page whit ajax.
#1

[eluser]tnathos[/eluser]
HI, i my proyect i have a login page.. the login works.. i use ajax for send user and password and retunr "1" or "2".. 1 = ok login, 2 = user and pwd bad.

the process works fine.. but when the user login.. in the same page appear in the footer the second page (page user) i use, redirect in php and in the script ajax for send the user to the new page.. but doesnt works..

this the code..

Code:
ajax...
function goLogin()
{
    $.ajax({
           type: "POST",
           url: "<?=base_url()?>index.php/User/loginUser/",
           cache: false,
           data: "email="+$("#email").val()+"&password;="+$("#password").val(),
           success: function(msg){
            if(msg=='2')
            {
            ("Usuario o ContraseƱa incorrecta");
            }else{
            location.href="<?=base_url()?>index.php/User/loadHome/"
            }

        }                
    });
    
}

Code:
controller
function loginUser()
    {
        $this->load->model('modelUser','loginObj');
        if($this->loginObj->login()){
        echo  "2";
    
        }else{
        echo  "2";
        }
            
    }
or..the same method but whit redirec

function loginUser()
    {
        $this->load->model('modelUser','loginObj');
        if($this->loginObj->login()){
            redirect('index.php/user/loadHome');
    
        }else{
        echo  "2";
        }
            
    }

Code:
load de the new view..

    function loadHome()
    {
        $this->load->view('user/home');    
    
    }

thanks for the advance
#2

[eluser]tnathos[/eluser]
ok problem solved, i have a session variable for controller the session.. but this variable have other name and allways show what the user not login. omg..




Theme © iAndrew 2016 - Forum software by © MyBB