Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php codeigniter:base#u url部分获胜';t重定向到我的控制器_Php_Codeigniter_Redirect - Fatal编程技术网

Php codeigniter:base#u url部分获胜';t重定向到我的控制器

Php codeigniter:base#u url部分获胜';t重定向到我的控制器,php,codeigniter,redirect,Php,Codeigniter,Redirect,我正在努力使登录工作。我对验证很在行,但当它重定向到另一个控制器以显示登录页面的视图时,我被卡住了。我对codeigniter还是个新手,对控制器的工作原理还不太清楚 这是我的控制器,用于验证登录用户: function index() { $this->form_validation->set_rules('studentid', 'studentid', 'trim|required|xss_clean'); $this->form_val

我正在努力使登录工作。我对验证很在行,但当它重定向到另一个控制器以显示登录页面的视图时,我被卡住了。我对codeigniter还是个新手,对控制器的工作原理还不太清楚

这是我的控制器,用于验证登录用户:

 function index() {
        $this->form_validation->set_rules('studentid', 'studentid', 'trim|required|xss_clean');
        $this->form_validation->set_rules('password', 'password', 'trim|required|xss_clean|callback_check_database');

        if($this->form_validation->run() == FALSE) {
            $this->load->view('v_login');
            } else {
                //Go to private area
                redirect(base_url('c_home'), 'refresh');
            }       
     }
它的功能是验证用户是否在数据库中,但是当用户成功登录时,它不会重定向到此重定向(base_url('c_home'),'refresh');它告诉我

Object not found!

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster.
这是c_home.php,应该在这里重定向:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class C_home extends CI_Controller {
    function __construct() {
        parent::__construct();
        $this->load->model('m_login','',TRUE);
        $this->load->helper('url');
        $this->load->library(array('form_validation','session'));
    }

    function index() {
        if($this->session->userdata('logged_in'))
        {
            $session_data = $this->session->userdata('logged_in');
            $data['studentid'] = $session_data['studentid'];
            $this->load->view('v_home', $data);
        } else {
        //If no session, redirect to login page
            redirect('c_login', 'refresh');
        }
    }

    function logout() {
         //remove all session data
         $this->session->unset_userdata('logged_in');
         $this->session->sess_destroy();
         redirect(base_url('c_login'), 'refresh');
     }

}

Codeigniter的重定向函数已经嵌入了站点url()

所以,不是这个,

redirect(base_url('c_login'), 'refresh');
正如您在前面的代码中所做的那样,使用此选项

redirect('c_login', 'refresh');

希望这有助于

Codeigniter的重定向功能已经嵌入了站点的url()

所以,不是这个,

redirect(base_url('c_login'), 'refresh');
正如您在前面的代码中所做的那样,使用此选项

redirect('c_login', 'refresh');

希望这对您有所帮助

您不需要重定向中的base_url()。只用

redirect('c_home',refresh);
虽然有两件事我应该让您知道,但您需要
('controller/function')
而不仅仅是
('controller')
。还要确保在两个控制器上的u构造函数中加载
$this->load->helper('url')

虽然只是为了将来的参考,我想这就是你的意思。
重定向(base\u url().'c\u home',刷新)
重定向中不需要base\u url()。只用

redirect('c_home',refresh);
虽然有两件事我应该让您知道,但您需要
('controller/function')
而不仅仅是
('controller')
。还要确保在两个控制器上的u构造函数中加载
$this->load->helper('url')

虽然只是为了将来的参考,我想这就是你的意思。
重定向(base\u url().'c\u home',刷新)

谢谢!我认为这很重要:)也谢谢你的提示
重定向(base_url().'c_home',refresh)
它对我不起作用…除非这个
重定向('c_home',refresh)
。调用ArrayTank上的成员函数站点时出错!我认为这很重要:)也谢谢你的提示
重定向(base_url().'c_home',refresh)
它对我不起作用…没有这个
重定向('c_home',refresh)
。调用数组上的成员函数site_url()时出错