【问题标题】:This page isn’t working is currently unable to handle this request. HTTP ERROR 500 in Codeigniter App此页面不工作目前无法处理此请求。 Codeigniter 应用程序中的 HTTP 错误 500
【发布时间】:2018-11-21 19:37:07
【问题描述】:

这是我的控制器功能,当点击登录时,网站应该重定向到 mysite.com/user/profile

这个profile()方法是,

public function profile(){
        $this->user = $this->session->userdata("user");
        if(empty($this->user)){
            redirect('login');
            exit;
        }

        $data["user"] = $this->crud->get_user($this->user["ID"]);
        $data["form_error"] = $this->session->flashdata('form_error');
        $data["csrf"] = array(
            'name' => $this->security->get_csrf_token_name(),
            'hash' => $this->security->get_csrf_hash()
        );
        $this->load->view('user/profile', $data);
        //$this->load->view('user/profile-static', $data);
    }

这是重定向到用户/配置文件方法的控制器代码

class Login extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->library('email');
        $this->load->library('form_validation');
        if(!empty($this->session->userdata("user"))){
            redirect('user/profile');
            //redirect('user/profile-static');
            exit;
        }
    }

但是页面上说 此页面无法使用 mysite.com 目前无法处理此请求。 HTTP 错误 500 请帮忙。 TIA

【问题讨论】:

  • 你如何重定向显示你的代码
  • 用这个来得到错误:ini_set('display_errors', TRUE);
  • 显示调用(或重定向)到profile()的代码
  • 与您的问题无关,但您可能想知道在redirect('login'); 之后对exit; 的调用将永远不会执行,因为redirect() 不会返回。
  • 朋友们,我已经更新了代码,请现在检查。 TIA

标签: php codeigniter login


【解决方案1】:

感谢大家的建议。我找到了解决办法。这是数据库中的错误。

我从 db 调用数据的模型函数在这里

public function get_user($id=""){
        $this->db->select("*");
        $this->db->where(array("ID" => $id));
        $query = $this->db->get("users");
        return $query->row_array();
    }

【讨论】:

    【解决方案2】:

    .htaccess 文件需要下面的代码。

    RewriteRule ^(.*)$ index.php/$1 [PT,L]  
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-04
      • 2017-12-19
      • 2019-01-02
      • 2017-10-21
      • 2018-12-05
      • 2020-05-01
      • 1970-01-01
      相关资源
      最近更新 更多