简体   繁体   中英

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.

So, how to pass form data in controller using GET method? 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.

As for GET variables .. you would have to use <form method="get" action="/what/ever/"> .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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