Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 352
Maulik patel Avatar asked Mar 28 '12 10:03

Maulik patel


2 Answers

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');
   }

}
like image 187
James Arnold Avatar answered Nov 14 '22 22:11

James Arnold


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

ONLY worked for me after I added the following line to applications/config/config.php:

$config['uri_protocol'] = "PATH_INFO";
like image 34
Maulik patel Avatar answered Nov 14 '22 22:11

Maulik patel