I want to check my application’s all post request. I have created a new route option.
$route['(:any)'] = 'any';
this will call any controller. This is my any.php
if ( !defined('BASEPATH') ) exit('No direct script access allowed');
class Any extends CI_Controller {
public function __construct() {
parent::__construct();
}
function index(){
if( $_POST ){
if( validate() ){
// redirect to error controller
}else{
//redirect to current page url
}
}else{
//redirect to current page url
}
}
}
But when i redirect via this function rediect($this->uri->uri_string), I got some error page. regarding cannot redirect to its self.
Is there any way to do this?
You are doing it wrong it will stuck in a redirect loop… after first time it will always invoke the else condition where you have put the redirect… You can either load a view in else condition or redirect to other function where you load a view.
UPDATE
Here is your work aorund for what you are trying to achieve:
Create a post_controller_construct hook with following code