Welcome Guest, Not a member yet? Register   Sign In
form submission - page not found
#1

[eluser]Unknown[/eluser]
I'm having a problem with a form and sometimes, for some records when you click on Save, it goes to the 404 page not found page. The controller is:

Code:
class Categories extends Controller {
function Categories()
{
   parent::Controller();
   $this->load->database();
   $this->load->helper('url');
   $this->load->helper('form');
   $this->load->library('session');
   $this->load->library('check_admin');
   $this->load->model('categories_model','categories');
   $this->load->model("offers_reviews_model","reviews");  
   $this->check_admin->check();
}
  
function index()
{
  $data['url'] = 'categories';
  $this->load->view('admin/body',$data);
}
function edit_offer()
{
  $this->db->where('id',$this->uri->segment(4));
  $query = $this->db->get('offers');
  $data['offer'] = $query->row();
  $data['url'] = 'editoffer';
  $this->load->view('admin/body',$data);
}

function edit_offer_content()
{
  $data['url'] = 'editoffercontent';
  $this->output->enable_profiler(TRUE);
  $this->db->where('id',$this->uri->segment(4));
  $query = $this->db->get('offers');
  $data['offer'] = $query->row();
  $this->load->view('admin/body',$data);
//  $this->load->view('admin/debug');
}

function edit_offer_content_success()
{
// var_dump($_POST['categories']); die();
  $this->output->enable_profiler(TRUE);
  $id = $this->input->post('id');
  $categories = $_POST['categories'];
  unset ($_POST['categories']);
  $this->db->where('id',$id);
  $this->db->update('offers',$_POST);
  $this->db->where('offer',$id);
  $this->db->delete('catalog');
  if ($categories)
  foreach ($categories as $categ)
  {
   $data['offer'] = $id;
   $data['category'] = $categ;
   $this->db->insert('catalog',$data);
  }
//  $this->load->view('admin/debug');
  redirect ('administration/categories/edit_offer/'.$id,'refresh');
}
From a menu page, a user selects the record they wish to edit, this then takes them to categories/edit_offer/RecordID function which opens the page editoffer with the chosen record shown. There is an edit link with the code:
Code:
<?php echo anchor('administration/categories/edit_offer_content/'.$offer->id, 'edit', array('title' => 'edit', 'style' => 'color:#FF0000'))?>]
This then takes them to the page editoffercontent with the record in a form for editing. When you click on the save button, it calls the edit_offer_content_success() function which saves the record. However, on some records, when you click on Save, it goes to the Page Not Found page. I've made it write out what page its looking for and its exactly correct. I've checked the record and I can see nothing in it that would break the form. If I inspect the rendered html of the form of a working record and a non working record, they are both exactly the same (apart from the record values) and I cannot see any reason why some records seem to break the form.

I didn't write this code, I'm trying to debug it. Anyone got any ideas of where I can start?
#2

[eluser]TheFuzzy0ne[/eluser]
Welcome to the CodeIgniter forums!

Please could you place code tags around that code? It makes it a lot easier to read.

[Image: sig_img_85998.png]




Theme © iAndrew 2016 - Forum software by © MyBB