Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting data from view to controller using Codeigniter
    primarykey
    data
    text
    <p>How can I pass the data input by user from view to controller in codeigniter Php using get or post method? I'm currently new to codeigniter..thanks!</p> <p>AddProduct.php (my view)</p> <pre><code>&lt;body&gt; &lt;form method="POST" action="SaveProductController"&gt;&lt;/br&gt;&lt;/br&gt;&lt;/br&gt; &lt;table border='1' align='center'&gt; &lt;tr&gt; &lt;td&gt;ID: &lt;/td&gt;&lt;td&gt;&lt;input type="text" name="id" value="&lt;?php echo $GetProductId-&gt;id + 1; ?&gt;" readonly="readonly"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Description: &lt;/td&gt;&lt;td&gt;&lt;input type="text" name="description"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="submit" name="addProduct" value="Add Product"&gt;&lt;td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/body&gt; </code></pre> <p>SaveProductController .php (my Controller)</p> <pre><code>class SaveProductController extends CI_Controller{ function index($description){ $this-&gt;load-&gt;model('ProductDao'); $data['id'] = $this-&gt;id; $data['description'] = $this-&gt;description; print_r($data); //$this-&gt;ProductDao-&gt;saveProduct(); } </code></pre> <p>}</p> <p>ProductDao.php</p> <pre><code> function saveProduct() { $data = array( 'id' =&gt; $this-&gt;input-&gt;xss_clean($this-&gt;input-&gt;post('id')), 'description' =&gt; $this-&gt;input-&gt;xss_clean($this-&gt;input-&gt;post('description')), 'price' =&gt; $this-&gt;input-&gt;xss_clean($this-&gt;input-&gt;post('price')), 'size' =&gt; $this-&gt;input-&gt;xss_clean($this-&gt;input-&gt;post('size')), 'aisle' =&gt; $this-&gt;input-&gt;xss_clean($this-&gt;input-&gt;post('aisle')), ); $query = $this-&gt;db-&gt;insert('mytable', $data); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload