无法重定向到其他页面

时间:2015-02-22 23:03:14

标签: php codeigniter google-chrome redirect

我正在使用此Codeigniter功能

redirect('home');

但它会导致我出现此浏览器错误:ERR_TOO_MANY_REDIRECTS

该页面甚至无法加载。

我的整个功能看起来像这样:

public function establish($target) {
    if ($target == 'sender' || $target == 'receiver') {
        $this->validate($target);
        if ($this->validated) {
            if ($target == 'sender') {
                $this->sender_db = $this->session->userdata('sender_db');
                $this->sender_host = $this->session->userdata('sender_host');
                $this->sender_user = $this->session->userdata('sender_user');
                $this->sender_pw = $this->session->userdata('sender_pw');
                if ($this->load->database($this->define_database('sender'))) {
                    $this->err_receiver = 0;
                    return $this->load->database($this->define_database('sender'), TRUE);
                }
                else {
                    $this->err_sender = 1;
                }
            }
            elseif ($target == 'receiver') {
                $this->receiver_db = $this->session->userdata('receiver_db');
                $this->receiver_host = $this->session->userdata('receiver_host');
                $this->receiver_user = $this->session->userdata('receiver_user');
                $this->receiver_pw = $this->session->userdata('receiver_pw');
                if ($this->load->database($this->define_database('receiver'))) {
                    $this->err_receiver = 0;
                    return $this->load->database($this->define_database('receiver'), TRUE);
                }
                else {
                    $this->err_receiver = 1;
                }
            }
            else {
                echo 'Error: illegal parameter. Please use sender or receiver instead.';
            }
        }
        else {
            echo 'Oops, there is an error! For some reason the property "validated" is not returning true (Connection_model.php)';
            exit;
        }
        redirect('home');
    }
    else {
        echo 'Error: illegal parameter. Please use sender or receiver instead.';
    }
}

我做错了什么?

1 个答案:

答案 0 :(得分:0)

我想出了这个问题。我正在经历一个无尽的循环。两页一遍又一遍地互相转发。