【问题标题】:Codeigniter Internal Server Error on redirect to another page重定向到另一个页面时出现 Codeigniter 内部服务器错误
【发布时间】:2015-11-20 05:32:57
【问题描述】:

我有以下功能,它应该在成功时重定向到另一个页面:

public function process() {


        $username = $this->input->post('username');
        $password = $this->input->post('password');
        // Validate the user can login

        $result = $this->login_model->validate($username, $password);
        // Now we verify the result
        if (!$result) {

            if (empty($password)) {
                $msg = '<font color=red>Invalid username and/or password.</font><br />';
                $this->index($msg);
            } else {

                $msg = '<font color=red>Invalid username and/or password.</font><br />';
                $this->index($msg);
            }
        } else {
            // If user did validate, 
            // Send them to members area
            redirect('home');
        }
    }

如果它有效,那么我应该被重定向到家,但不幸的是我收到以下错误:

HTTP ERROR: 500

Internal Server Error

RequestURI=http://system.uniqueloo.co.ke/login/process

是否有另一种方法可以在不使用 php 重定向功能的情况下在 codeigniter 中进行重定向?

【问题讨论】:

  • 你检查htaccess文件了吗?

标签: php .htaccess codeigniter redirect


【解决方案1】:

确保索引函数接受传入参数

在控制器中

public function process() {

    $username = $this->input->post('username');
    $password = $this->input->post('password');

    $result = $this->login_model->validate($username, $password);

    if (isset($result)) { #change this

        if (empty($password)) {

            $msg = '<font color=red>Invalid username and/or password.</font><br />';
            $this->index($msg); # not sure about this
        } 
        else {

            $msg = '<font color=red>Invalid username and/or password.</font><br />';
            $this->index($msg); # not sure about this
        }
    } 
    else {

        redirect('home');
    }
}

【讨论】:

    猜你喜欢
    • 2018-08-06
    • 2017-10-01
    • 1970-01-01
    • 2013-03-09
    • 2018-01-26
    • 1970-01-01
    • 1970-01-01
    • 2015-10-10
    • 1970-01-01
    相关资源
    最近更新 更多