简体   繁体   English

如何使用codeigniter中的GET方法将表单数据发布到控制器

[英]how to post a form data to controller using GET method in codeigniter

my view: 我的看法:

<form action="<?=base_url()?>index.php/frontend/main_con/temp">
    <input type="text" name="temp">
    <input type="submit"/>
</form>

Controller: 控制器:

function temp(){
    echo $_GET['temp'];
}

i cant able to reach this function and i got an error 我无法达到此功能,我收到了一个错误

An Error Was Encountered The URI you submitted has disallowed characters. 遇到错误您提交的URI不允许使用字符。

So, how to pass form data in controller using GET method? 那么,如何使用GET方法在控制器中传递表单数据? thanx in advance. 提前。

View: 视图:

<form action="<?=site_url('controller_name/function_name);?>" method="get">
    <input type="text" name="temp">
    <input type="submit"/>
</form>

Controller 调节器

class controller_name extends CI_Controller{

   function function_name(){
      echo $this->input->get('temp');
   }

}
parse_str($_SERVER['QUERY_STRING'],$_GET);

在将以下行添加到applications / config / config.php后,仅对我有用:

$config['uri_protocol'] = "PATH_INFO";

To solve the error go to this line . 要解决错误,请转到此行 I personally think, that this is a mistake by design, because black-listing symbols from URI would be much better then white-listing. 我个人认为,这是设计上的一个错误,因为来自URI的黑名单符号会比白名单更好。

As for GET variables .. you would have to use <form method="get" action="/what/ever/"> . 至于GET变量..你必须使用<form method="get" action="/what/ever/">

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

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