简体   繁体   English

代码点火器未在控制器中运行该方法

[英]Code Igniter not running the method in the controller

I have a form in a view called login_view that I would like to target a function in the Login controller. 我在一个名为login_view的视图中有一个表单,我希望在Login控制器中定位一个函数。

For my form in login_view I have echo form_open('/Login/validate_credentials'); 对于我的login_view中的表单,我具有echo form_open('/Login/validate_credentials');

In my Login.php controller I have: 在我的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');
    }
}
?>  

When I submit the form from the browser, instead of loading the welcome2 view like I expect, it tries to load the URL of: 当我从浏览器提交表单时,它没有尝试加载我期望的URL,而是尝试加载以下URL:

localhost/project/Login/validate_credentials

and I just see the default page for WAMP. 我只看到WAMP的默认页面。

It's my first day in Code Igniter so I'm sure the answer is simple. 这是我在Code Igniter中的第一天,所以我相信答案很简单。

Just replace your controller construct by this: 只需替换您的控制器构造:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM