How to send php variable from view(html) to controller -
this html code. want pass "$category_edit->c_name
" value update()
controller. getting "$category_edit
" variable controller.
i using codeigniter framework.
<form method="post" action="<?php echo base_url('admin/category/update');?>"> <label>parent category: </label></br> <select name="parent_id"> <?php echo '<option value="' .$category_edit->id .'">'; echo $category_edit->p_name; echo '</option>'; ?> </select> <label>category</label> <input type="text" name="<?php echo $category_edit->c_name; ?>" id="category_name" value="<?php echo $category_edit->c_name; ?>"> <button>update</button> </form>
this update()
controller. getting error:
- undefined variable: category_edit
trying property of non-object
public function update(){ $this->load->model('category_model'); echo $category_edit->c_name; }
please kindly check reference code:
public function update_view() { $this->load->model('category_model'); $data['category_edit'] = $this->category_model->get_category_values(); // return array $data['extra_variable'] = 'lorem ipsum'; $this->load->view('category/update_view', $data); }
at category/update_view.php
:
<form method="post" action="<?php echo base_url('admin/category/update');?>"> <label>parent category: </label></br> <select name="parent_id"> <?php echo '<option value="' .$category_edit['id'] .'">'; echo $category_edit['p_name']; echo '</option>'; ?> </select> <label>category</label> <input type="text" name="<?php echo $category_edit['c_name']; ?>" id="category_name" value="<?php echo $category_edit['c_name']; ?>"> <button>update</button> </form>
edit:
please refer: http://www.codeigniter.com/user_guide/general/views.html#adding-dynamic-data-to-the-view
Comments
Post a Comment