0

I am new to CodeIgniter and specially RESTful services. I am using Phil Sturgeon's RESTful API Server.

Now in examples there are no models and the response is shown on the initial view where all the links are.

But what I want is that I want to log the user in and if their credentials are okay then load a new view and send the data (response data) there.

This always gives me exceptions. Can someone explain what is happening>

My controller code:

function details_post()
    {
        $user_name = $this->post('username');
        $pwd= $this->post('password');
        echo $pwd;
        if($pwd){
            $this->load->model('login_model');
            $result=$this->login_model->login($user_name,$pwd);

        if($result){
                $user_id=$this->session->userdata['logged_in']['userid'];
                $this->load->model('loadposts_model');
                //$data['response']=$this->response("ok", 200);
                $data['query']=$this->loadposts_model->load_post($user_id);
                $data['name'] = $result;
                $this->load->view('CiscoGurus/user_newsfeed', $data); 
                    //$this->response($data, 200);
                    }
                if($result==false) {
                $data['error_message'] = 'User name or password is incorrect!!!';
                    $this->load->view('CiscoGurus/index', $data);}
    }
    }
Giacomo1968
  • 25,759
  • 11
  • 71
  • 103

1 Answers1

1

You can't render a view and send a response. If you're using RESTful services you will need to retun a response to the client which will parse it and show it to the user.

  • Okey but even if I return response, I still get error and how exactly will I be able to return the response and display it on my desired view? – user3607883 May 08 '14 at 05:11