index.php/frontend/main_con/...">

How to submit form data to a controller using the GET method in codeigniter

my opinion:

<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 cannot reach this function and I got an error

An error has been detected. The URI you submitted has illegal characters.

So, how to transfer form data to the controller using the GET method? than in advance.

+4
source share
4 answers
 parse_str($_SERVER['QUERY_STRING'],$_GET); 

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

 $config['uri_protocol'] = "PATH_INFO"; 
+2
source

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

To resolve this error, go to this line . I personally think this is a design mistake, because blacklisted characters from a URI will be much better than a whitelist.

As for the GET variables .. you will need to use <form method="get" action="/what/ever/"> .

+1
source
+1
source

Source: https://habr.com/ru/post/1403864/


All Articles