Php 视图中的按钮不显示';控制器中的t调用方法
我有一个问题:我有一个视图需要在我的控制器EmployeeController中调用一个方法才能转到页面添加员工。但是它不起作用。。也与其他意见,它没有 这是一种观点:Php 视图中的按钮不显示';控制器中的t调用方法,php,html,model-view-controller,Php,Html,Model View Controller,我有一个问题:我有一个视图需要在我的控制器EmployeeController中调用一个方法才能转到页面添加员工。但是它不起作用。。也与其他意见,它没有 这是一种观点: <body> <form class="form-horizontal" id='employeeform' id='employeeform' action="<?php echo base_url();?>EmployeeController/addEmployee" meth
<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>
我得到的错误是:
在此服务器上找不到请求的URL/BoMaTec_afstudeerproject/CodeIgniter-3.0.1/EmployeeController/createEmployee。似乎您没有用于该URL的任何路由器,或者路由器错误。根据错误,它试图加载一个名为
EmployeeController
的文件夹,并在该文件夹中加载另一个名为createEmployee
的文件夹。检查你的.htaccess文件和你正在使用的框架中的路由器。似乎你没有用于该url的路由器,或者路由器是错误的。根据错误,它试图加载一个名为EmployeeController
的文件夹,并在该文件夹中加载另一个名为createEmployee
的文件夹。检查您正在使用的框架中的.htaccess文件和路由器。如果从视图中的表单操作中删除
,它是否有效?为什么表单标签上有两个id<代码>id='employeeform'id='employeeform'。另外,当您在开发工具中查看表单时,html显示为表单的操作是什么?否。。我添加了基本url,因为我在互联网上发现它更好。但是如果没有,它将不起作用。如果从视图中的表单操作中删除
,它会起作用吗?为什么表单标记上有两个id<代码>id='employeeform'id='employeeform'。另外,当您在开发工具中查看表单时,html显示为表单的操作是什么?否。。我添加了基本url,因为我在互联网上发现它更好。但是如果没有,这一切都不起作用。你知道我需要补充什么吗?那可能是,你知道我需要补充什么吗?
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
}
}
?>