I have a function called "insert" in my categories controller. When I call the function via url like this: /categories/insert it works OK, but if I call the function like this: /categories/insert/ (slash at the end) the function is called three times.
Even when a call my edit function like this: /categories/edit/2 - the edit function is called three times.
In config/routes.php I only have default route. My .htaccess is this:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|include|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
EDIT:
The code for the edit function:
public function edit($id = '')
{
$this->load->helper("form");
$this->load->library("form_validation");
$data["title"] = "Edit category";
$this->form_validation->set_rules('category_name', 'Category name', 'required');
if (!$this->form_validation->run())
{
$data['category'] = $this->categories_model->get_categories($id);
$this->load->view("templates/admin_header", $data);
$this->load->view("categories/edit", $data);
$this->load->view("templates/admin_footer", $data);
}
else
{
$this->categories_model->update($id);
// other logic
}
}