1

我遇到了一些奇怪的错误(CodeIgniter):

调用未定义的函数 view()。

但是我使用登录作为默认控制器。index() 正在完美地加载页面,而在函数中加载视图不起作用。

 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');


 class Login extends CI_Controller{



public function index(){
    $this->load->view('login_view');
}

public function processLogin(){
    if(isset($_POST['username']) && isset($_POST['password'])){
        if(!empty($_POST['username']) && !empty($_POST['password'])){
            $this->load->model("user");
            $suc = $this->user->login($_POST['username'],$_POST['password']);

            if($suc !=0 && $suc !=-1){

            }
            else{
                if($suc == 0){
                    $data['error'] = "Invalid credentials";
                    $this->load>view('login_view',$data);
                }
                else{
                    $data['error'] = "Multiple user exist with same logon";
                    $this->load>view('login_view',$data);
                }


            }

        }
    }
}



}

?>
4

1 回答 1

0

你错过了一个-附近>

改变这个:

 if($suc == 0){
                    $data['error'] = "Invalid credentials";
                    $this->load>view('login_view',$data);
                }
                else{
                    $data['error'] = "Multiple user exist with same logon";
                    $this->load>view('login_view',$data);
                }

对此:

if($suc == 0){
                $data['error'] = "Invalid credentials";
                $this->load->view('login_view',$data);
            }
            else{
                $data['error'] = "Multiple user exist with same logon";
                $this->load->view('login_view',$data);
            }

我在两行中对此进行了更改:$this->load>view对此:$this->load->view

于 2013-10-10T19:02:19.013 回答