【发布时间】:2016-03-13 02:14:38
【问题描述】:
我想将输入文本发布到我的控制器,但是当我运行“页面未正确重定向”时出现错误,并且 index.php 会自动出现在 url 中,例如“http://localhost:1337/PhpProject1/search_profile_controller/Index.php”。我已经通过 htaccess 从我的网址中删除了 index.php !我的代码在这里
class Search_profile_controller extends CI_Controller{
public function profile_clicked(){
$data = $this->input->post('input_profile');
$this->load->view('profile_view',$data);
echo $data;
}
}
我的html
<form id="frm" name="frm" action="http://localhost:1337/PhpProject1/search_profile_controller/profile_clicked" method="post" >
// I input value from jquery and submit it dynamically
</form>
我的路由.php
$route['search_profile_controller/(:any)'] = 'search_profile_controller';
$route['search_profile_controller/(:any)'] = 'search_profile_controller/profile_clicked';
【问题讨论】:
-
只是一个想法,您可以使用 codeigniter 表单助手来查看,从而节省您输入完整的 url。 codeigniter.com/user_guide/helpers/form_helper.html
-
更改您的路线文件。删除这两行并写入 $route['search_profile_controller'] = 'search_profile_controller/profile_clicked';
标签: php codeigniter