Welcome Guest, Not a member yet? Register   Sign In
undefined index
#1

[eluser]swgj19[/eluser]
I am getting the error. I am not sure why. Because my categories model and post model is working just fine with similar functions. I know this is not a db error as I have already tested.

Error:

A PHP Error was encountered
Severity: Notice

Message: Undefined index: name

Filename: views/admin_comments_edit.php

Line Number: 9

This error is happening for every name of field in my form.

View:

Code:
<br />
<h1>&lt;?php echo $title;?&gt;</h1>

&lt;?php
echo form_open('admin/posts/edit');
echo "<p><label for='ptitle'>Title</label><br/>";
$data = array('name'=>'title','id'=>'ptitle','size'=>25, 'value' =>$post['title']);
echo form_input($data) ."</p>";

echo "<p><label for='ptags'>Tags</label><br/>";
$data = array('name'=>'tags','id'=>'ptags','size'=>25, 'value' =>$post['tags']);
echo form_input($data) ."</p>";

echo "<p><label for='category_id'>Category </label><br/>";
echo form_dropdown('category_id', $cats, $post['category_id']) ."</p>";

echo "<p><label for='long'>Content</label><br/>";
$data = array('name'=>'body','id'=>'long','rows'=>5, 'cols'=>'40', 'value' =>$post['body']);
echo form_textarea($data) ."</p>";

echo "<p><label for='status'>Status</label><br/>";
$options = array('draft' => 'draft', 'published' => 'published');
echo form_dropdown('status', $options,  $post['status']) ."</p><br />";

echo form_hidden('id', $post['id']);
echo form_submit('submit', 'update page');
echo form_close();
?&gt;
<br />

controller

Code:
&lt;?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Comments extends CI_Controller {

// --------------------------------------------------------------------

/**
  * __construct()
  *
  * Constructor PHP 5+ NOTE: Not needed if not setting values!
  *
  * @access public
  * @return void
  */
public function __construct()
{
  parent::__construct();

  $this->load->model('comment_model', 'comments');

  if ($this->session->userdata('user_id') < 1)
  {
   redirect('blog/login', 'refresh');
  }
}

// --------------------------------------------------------------------

/**
  * index()
  *
  * Description:
  *
  * @access public
  * @return void
  */
public function index()
{
  $data['title']  = "Manage Comments";
  $data['main']  = 'admin_comments_home';
  $data['comments'] = $this->comments->get_all_comments();

  $this->load->vars($data);
  $this->load->view('dashboard');  
}

// --------------------------------------------------------------------

/**
  * create()
  *
  * Description:
  *
  * @access public
  * @return void
  */  
public function create()
{

  if ($this->input->post('name'))
  {
   $this->comments->add_comment();
   $this->session->set_flashdata('message', 'Comment created');

   redirect('admin/comments/index', 'refresh');
  }
  else
  {
   $data['title']  = "Create Comment";
   $data['main']  = 'admin_comments_create';
   $data['comments'] = $this->comments->get_comments();

   $this->load->vars($data);
   $this->load->view('dashboard');    
  }
}

// --------------------------------------------------------------------

/**
  * edit()
  *
  * Description:
  *
  * @access public
  * @param string
  * @return void
  */
function edit($id=0){
   if ($this->input->post('name')){
    $this->comments->update_comment();
    $this->session->set_flashdata('message','Comment updated');
    redirect('admin/comments/index','refresh');
   }else{
  
  //$id = $this->uri->segment(4);
  $data['title'] = "Edit Comment";
  $data['main'] = 'admin_comments_edit';
  $data['comment'] = $this->comments->get_comments($id);
  $data['comments'] = $this->comments->get_all_comments();
  $this->load->vars($data);
  $this->load->view('dashboard');    
}
  }  


// --------------------------------------------------------------------

/**
  * delete()
  *
  * Description:
  *
  * @access public
  * @param string
  * @return void
  */
public function delete($id = 0)
{
  $this->comments->delete_comment($id);
  $this->session->set_flashdata('message', 'Comment deleted');

  redirect('admin/comments/index', 'refresh');
}

}


// ------------------------------------------------------------------------
/* End of file admin_model.php */
/* Location: ./application/models/admin_model.php */


Messages In This Thread
undefined index - by El Forum - 11-27-2012, 01:53 AM
undefined index - by El Forum - 11-27-2012, 01:54 AM
undefined index - by El Forum - 11-27-2012, 04:12 AM
undefined index - by El Forum - 11-27-2012, 04:44 AM
undefined index - by El Forum - 11-27-2012, 05:06 AM
undefined index - by El Forum - 11-27-2012, 05:07 AM
undefined index - by El Forum - 11-27-2012, 05:35 AM
undefined index - by El Forum - 11-27-2012, 05:44 AM
undefined index - by El Forum - 11-27-2012, 05:56 AM
undefined index - by El Forum - 11-27-2012, 06:07 AM
undefined index - by El Forum - 11-27-2012, 06:21 AM
undefined index - by El Forum - 11-27-2012, 06:23 AM
undefined index - by El Forum - 11-27-2012, 07:49 AM
undefined index - by El Forum - 11-27-2012, 09:30 AM
undefined index - by El Forum - 11-27-2012, 09:39 AM
undefined index - by El Forum - 11-27-2012, 10:08 AM
undefined index - by El Forum - 11-27-2012, 01:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB