title: Undefined Index Error Codeigniter
body: <p>I am trying to edit a specific customer's details. The data is arriving from database and displaying the correct array result when i <code>var_dump</code> the variable, but its not showing in the text field and an undefined index error is there. Help me out in solving this</p>
  
  <p>This is my controller code:</p>
  
  <pre><code>&lt;?php
  class Helpdesk extends CI_Controller {
  
  public function __construct()
  {
      parent::__construct();
      $this-&gt;load-&gt;model('crmstaff/helpdesk_model');
  }
  
  public function index()
  {
  if($this-&gt;session-&gt;userdata('isLogin') == FALSE)
  {
    redirect('login ');
  }else
  {
    $this-&gt;load-&gt;model('crmstaff/m_login');
  
    $user = $this-&gt;session-&gt;userdata('username');
  
    $data['level'] = $this-&gt;session-&gt;userdata('level');        
    $data['user'] = $this-&gt;m_login-&gt;userData($user);
  
  $this-&gt;load-&gt;helper('form');
  $this-&gt;load-&gt;helper('url');
  
  $data['customer'] = $this-&gt;helpdesk_model-&gt;get_pending_profile();
  $data['title'] = 'Customer Details';
  
  $this-&gt;load-&gt;view('website/crmstaff/general/header1', $data);
  $this-&gt;load-&gt;view('website/crmstaff/helpdesk/index', $data);
  $this-&gt;load-&gt;view('website/crmstaff/general/footer1', $data);
  
  }
  }
  public function edit_permission($id=null) 
  {   
  if($this-&gt;session-&gt;userdata('isLogin') == FALSE)
  {
    redirect('login ');
  }else
  {
    $this-&gt;load-&gt;model('crmstaff/m_login');
  
    $user = $this-&gt;session-&gt;userdata('username');
  
    $data['level'] = $this-&gt;session-&gt;userdata('level');        
    $data['user'] = $this-&gt;m_login-&gt;userData($user);
  
   $this-&gt;load-&gt;helper('form');
   $this-&gt;load-&gt;helper('url');
  if($this-&gt;input-&gt;post('name'))
   {
      $data['customers'] = $this-&gt;helpdesk_model-&gt;edit_permission($this-  &gt;input-&gt;post('id'));                
  
      //var_dump($data);
  
      if (empty($data['customers']))
      {
          show_404();
      }
  //      redirect('tower/index');
      redirect('helpdesk/index', 'location', 301);
   }
   else
   {
       $data['customers']=$this-&gt;helpdesk_model-&gt;get_pending_profile($id);
       //print_r($data);
      // var_dump($data);
          //var_dump ($this-&gt;db-&gt;last_query());        
       $this-&gt;load-&gt;view('website/crmstaff/helpdesk/edit', $data);
   }
  }
  }
  }
  ?&gt;
  </code></pre>
  
  <p>Model Code:</p>
  
  <pre><code>&lt;?php
  class Helpdesk_model extends CI_Model {
  
  public function __construct()
  {
      $this-&gt;load-&gt;database();
  }
  public function get_custdetails($id = FALSE)
  {
  if ($id === FALSE)
  {
      $query = $this-&gt;db-&gt;get('customers');
      return $query-&gt;result_array();
  }
  
  $query = $this-&gt;db-&gt;get_where('customers', array('customerId' =&gt; $id));
  //  echo $this-&gt;db-&gt;last_query();
  return $query-&gt;row_array();
  }
  
  public function get_pending_profile()
  {
  $query = $this-&gt;db-&gt;get('customers');
  $where = "applicationStatus = 'SALES_CHECK_OK'";
  $query = $this-&gt;db-&gt;get_where('customers', $where);
  
      return $query-&gt;result_array();
  //  echo $this-&gt;db-&gt;last_query();
  return $query-&gt;row_array();
  }
  
  
  
  public function edit_permission($id)
  {
  $data = array(
      'applicationStatus' =&gt; $this-&gt;input-&gt;post('status')
  );
  
  $this-&gt;db-&gt;where('customerId', $id);
  $this-&gt;db-&gt;update('customers', $data); 
  return $query = $this-&gt;db-&gt;get_where('customers', array('customerId' =&gt; $id))-&gt;row_array();
  }
  }
  
  ?&gt;
  </code></pre>
  
  <p>in View:</p>
  
  <pre><code>&lt;?php echo form_open('helpdesk/edit_permission');?&gt;
  &lt;?php var_dump ($customers); ?&gt;
  &lt;form method="get" class="form-horizontal"&gt;
   &lt;div class="form-group"&gt;&lt;label class="col-sm-2 control-label"&gt;Customer Name&lt;/label&gt;                                    
   &lt;div class="col-sm-10"&gt;&lt;input type="text" class="form-control" name="name" value="&lt;?php echo $customers['customerName']; ?&gt;"&gt;&lt;/div&gt;
  
                              &lt;/div&gt;
                              &lt;div class="form-group"&gt;&lt;label class="col-sm-2 control-label"&gt;Address&lt;/label&gt;
  
                                  &lt;div class="col-sm-10"&gt;&lt;input type="text" class="form-control" name="add" value="&lt;?php echo $customers['customerAddress']; ?&gt;"&gt;&lt;/div&gt;
                              &lt;/div&gt;
                              &lt;div class="form-group"&gt;&lt;label class="col-sm-2 control-label"&gt;Email Address&lt;/label&gt;
  
                                  &lt;div class="col-sm-10"&gt;&lt;input type="text" class="form-control" name="payment" value="&lt;?php echo $customers['email1']; ?&gt;"&gt;&lt;/div&gt;
                              &lt;/div&gt;
                              &lt;div class="form-group"&gt;&lt;label class="col-sm-2 control-label"&gt;Application Status&lt;/label&gt;
  
                                  &lt;div class="col-sm-10"&gt;
                                  Activate: &lt;input type="checkbox" value="SALES_CHECK_OK" name="status" /&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                              &lt;input type="hidden" value="&lt;?php echo $customers['customerId']; ?&gt;" name="id" /&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;div class="col-sm-4 col-sm-offset-2"&gt;
                                      &lt;button class="btn btn-white" type="submit"&gt;Cancel&lt;/button&gt;
                                      &lt;button class="btn btn-primary" type="submit"&gt;Update&lt;/button&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/form&gt;
  </code></pre>
  
  <p>in the view i an getting the error</p>
  
  <p>A PHP Error was encountered</p>
  
  <pre><code>Severity: Notice
  Message: Undefined index: customerName
  Filename: helpdesk/edit.php
  Line Number: 114
  </code></pre>
  
  <p>Output of var_dump($customers);</p>
  
  <pre><code>array(1) {
   [0]=&gt;
   array(37) {
  ["customerId"]=&gt;
  string(1) "5"
  ["customerName"]=&gt;
  string(7) "Geetika"
  ["customerDOB"]=&gt;
  string(10) "0000-00-00"
  ["house"]=&gt;
  string(0) ""
  ["customerProfession"]=&gt;
  string(0) ""
  ["previousISP"]=&gt;
  string(1) "0"
  ["customerPaymentDetails"]=&gt;
  NULL
  ["chqNo"]=&gt;
  string(1) "0"
  ["bankName"]=&gt;
  string(0) ""
  ["date"]=&gt;
  string(10) "0000-00-00"
  ["amount"]=&gt;
  string(1) "0"
  ["customerAddress"]=&gt;
  string(15) "ambamata scheme"
  ["city"]=&gt;
  string(0) ""
  ["state"]=&gt;
  string(0) ""
  ["pin"]=&gt;
  string(1) "0"
  ["phnoRes"]=&gt;
  string(1) "0"
  ["phnoOffice"]=&gt;
  string(1) "0"
  ["phnoMobile"]=&gt;
  string(1) "0"
  ["billAddress"]=&gt;
  string(0) ""
  ["billCity"]=&gt;
  string(0) ""
  ["billState"]=&gt;
  string(0) ""
  ["billPin"]=&gt;
  string(1) "0"
  ["billPhnoRes"]=&gt;
  string(1) "0"
  ["billPhnoOffice"]=&gt;
  string(1) "0"
  ["billPhnoMobile"]=&gt;
  string(1) "0"
  ["idProof"]=&gt;
  string(0) ""
  ["email1"]=&gt;
  string(20) "gitikajsh619@gmail.c"
  ["email2"]=&gt;
  string(0) ""
  ["hardware"]=&gt;
  string(0) ""
  ["staticIP"]=&gt;
  string(1) "0"
  ["applicationStatus"]=&gt;
  string(14) "SALES_CHECK_OK"
  ["planType"]=&gt;
  string(6) "1month"
  ["planDuration"]=&gt;
  string(0) ""
  ["wirelessRouter"]=&gt;
  string(0) ""
  ["macIDOFCPE"]=&gt;
  NULL
  ["TowerID"]=&gt;
  NULL
  ["message"]=&gt;
  string(14) "new connection"
   }
  </code></pre>