视图中的按钮不调用控制器中的方法


Button in view doesn't call method in controller

我有一个问题:我有一个视图,需要在我的控制器EmployeeController中调用一个方法来转到页面添加员工。但是行不通……对于其他视图,它也是

这是视图:

<body>
         <form class="form-horizontal" id='employeeform' id='employeeform' action="<?php echo base_url();?>EmployeeController/addEmployee" method="post">
          <div class="container">
          <div class="row">
          <div class="col-lg-12 col-sm-12">
               <table class="table table-striped table-hover">
                    <thead>
                         <tr>
                              <th>#</th>
                              <th>ID</th>
                              <th>Naam werknemer</th>
                          <th>Datum aanwerving</th>
                          <th>Salaris</th>
                     </tr>
                </thead>
                <tbody>
                     <?php for ($i = 0; $i < count($employeelist); ++$i) { ?>
                          <tr>
                               <td><?php echo ($i+1); ?></td>
                               <td><?php echo $employeelist[$i]->employee_no; ?></td>
                               <td><?php echo $employeelist[$i]->employee_name; ?></td>
                               <td><?php echo $employeelist[$i]->hired_date; ?></td>
                               <td><?php echo $employeelist[$i]->salary; ?></td>
                          </tr>
                     <?php } ?>
                </tbody>
           </table>
        <input id="btn_add" name="btn_add" type="submit" class="btn btn-primary" value="Add employee" />
      </div>
      </div>
      </div>
      </form>
     </body>

这是控制器:

类EmployeeController扩展CI_Controller {

public function __construct() {
    parent::__construct();
    $this->load->library('session');
    $this->load->helper('form');
    $this->load->helper('url');
    $this->load->database();
    $this->load->library('form_validation');
    //load the employee model
    $this->load->model('employee_model');
}
//index function
function index() {
    $employeelist = $this->employee_model->get_employee_list();
    $data['employeelist'] = $employeelist;
    $this->load->view('employee/employee_add', $data);
}
function createEmployee() {
    $this->form_validation->set_rules('employee_no', 'Employee No', 'trim|required|numeric');
    $this->form_validation->set_rules('employee_name', 'Employee Name', 'trim|required|xss_clean|callback_alpha_only_space');
    $this->form_validation->set_rules('hired_date', 'Hired Date', 'required');
    $this->form_validation->set_rules('salary', 'Salary', 'required|numeric');
    if ($this->form_validation->run() == FALSE) {
        //fail validation
        $this->load->view('employee/employee_add');
    } else {
        //pass validation
        $data = array(
            'employee_no' => $this->input->post('employeeno'),
            'employee_name' => $this->input->post('employeename'),
            'hired_date' => @date('Y-m-d', @strtotime($this->input->post('hireddate'))),
            'salary' => $this->input->post('salary'),
        );
        //insert the form data into database
        $this->db->insert('tbl_employee', $data);
        //display success message
        $employeeresult = $this->employee_model->get_employee_list();
        $data['employeelist'] = $employeeresult;
        //load the department_view
        $this->load->view('employee/employee_view', $data);
        redirect('employee/employee_view');
    }
}
function addEmployee() {
    $this->load->view('employee/employee_add');
    //set validation rules
}
}
?>
我得到的错误是:请求的URL/bomatec_afstudenterproject/CodeIgniter-3.0.1/EmployeeController/createEmployee在此服务器上找不到

似乎你没有任何路由器的url,或路由器是错误的。根据错误,它试图加载一个名为EmployeeController的文件夹,并在该文件夹中,另一个名为createEmployee的文件夹。检查你的。htaccess文件和你使用的框架中的路由器。