Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.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 Ion Auth在登录期间未正确重定向_Php_Codeigniter_Routes_Ion Auth - Fatal编程技术网

Php Ion Auth在登录期间未正确重定向

Php Ion Auth在登录期间未正确重定向,php,codeigniter,routes,ion-auth,Php,Codeigniter,Routes,Ion Auth,我正在使用ion auth为我的codeigniter应用程序创建一个登录系统。我已经为更好的URL创建了路由,例如: http://localhost/myApplication/index.php/auth/login 现在是 http://localhost/myApplication/index.php/login 我用来实现这一点的“路由规则”是 $route['login'] = 'auth/login'; 它工作正常,也就是说,直接在浏览器的地址栏中输入它会让我进入登录页面。

我正在使用ion auth为我的codeigniter应用程序创建一个登录系统。我已经为更好的URL创建了路由,例如:

http://localhost/myApplication/index.php/auth/login
现在是

http://localhost/myApplication/index.php/login
我用来实现这一点的“路由规则”是

$route['login'] = 'auth/login';
它工作正常,也就是说,直接在浏览器的地址栏中输入它会让我进入登录页面。登录时出现问题。当我点击“登录”按钮时,我会被引导回

http://localhost/myApplication/index.php/auth/login
当然,我会得到一个“404页面未找到”错误。我不知道是ion auth的哪一部分导致了这种行为。我已经检查了
auth.php
控制器的
login()
方法,但那里没有任何东西(据我所知)是罪魁祸首

我的routes.php如下所示

$route['default_controller'] = "pages/view";
$route['404_override'] = '';

$route['login'] = 'auth/login';
$route['register'] = 'auth/create_user';

$route['(:any)'] = 'pages/view/$1';
以及
login()
mehod

//log the user in
function login()
{
    $this->data['title'] = "Login";

    //validate form input
    $this->form_validation->set_rules('identity', 'Identity', 'required');
    $this->form_validation->set_rules('password', 'Password', 'required');

    if ($this->form_validation->run() == true)
    {
        //check to see if the user is logging in
        //check for "remember me"
        $remember = (bool) $this->input->post('remember');

        if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'), $remember))
        {
            //if the login is successful
            //redirect them back to the home page
            $this->session->set_flashdata('message', $this->ion_auth->messages());
            redirect('/', 'refresh');
        }
        else
        {
            //if the login was un-successful
            //redirect them back to the login page
            $this->session->set_flashdata('message', $this->ion_auth->errors());
            redirect('auth/login', 'refresh'); //use redirects instead of loading views for compatibility with MY_Controller libraries
        }
    }
    else
    {
        //the user is not logging in so display the login page
        //set the flash data error message if there is one
        $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');

        $this->data['identity'] = array('name' => 'identity',
            'id' => 'identity',
            'type' => 'text',
            'value' => $this->form_validation->set_value('identity'),
        );
        $this->data['password'] = array('name' => 'password',
            'id' => 'password',
            'type' => 'password',
        );

        $this->_render_page('login', $this->data);
    }
}

我很欣赏任何有助于揭开这个谜团的观点。谢谢。

您需要打开
视图/auth/login.php
并进行更改

<?php echo form_open("auth/login");?>

致:


答案似乎就在那里,藏在眼前,谢谢@joni。
<?php echo form_open("login");?>