Code Igniter 不是 运行 控制器中的方法

Code Igniter not running the method in the controller

我在名为 login_view 的视图中有一个表单,我想将其作为登录控制器中的一个函数的目标。

对于 login_view 中的表格,我有 echo form_open('/Login/validate_credentials');

在我的 Login.php 控制器中,我有:

<?php if (! defined('BASEPATH')) exit('No direct script access allowed');

class Login extends CI_Controller{

    function __construct()
    {
        parent::__construct();
    }

    public function validate_credentials(){
        $this->load->view('welcome2');
    }
}
?>  

当我从浏览器提交表单时,它没有像我期望的那样加载 welcome2 视图,而是尝试加载 URL of:

localhost/project/Login/validate_credentials

我只看到 WAMP 的默认页面。

这是我第一天使用 Code Igniter,所以我相信答案很简单。

只需将您的控制器结构替换为:

 public function __construct()
 {
    parent::__construct();
    $this->load->helper(array('url','text','html','form','string'));
}