Search code examples
databasecodeigniterrecords

Codeigniter updating database record list


Ok i have in view file record form db and i am trying to pass it to controler, then to method where i try to do update

$this->db->select('info');
$query = $this->db->get('pages');
 foreach ($query->result() as $q): ?>
<a href="update/updating/<?php echo $q->info?>"><?php echo $q->info . br()?></a>

in my controler i have code

public function updating($var){
        $data['info']= $var;
        $this->load->view("view_update",$data);

} which load view file where i want to insert new value with form

echo br() . $this->session->flashdata('item');
echo '<h4>Azuriranje Podataka </h4>';
echo "Old data is:" .$info;


echo form_open('update/updating');

$data = array('name'=>'field');
echo form_input().br().br();
echo form_submit('mysubmit', 'Posalji');
echo form_close()

my question what should i do with $info i dont wanna submit it via form and input field how to grab it again in controler???


Solution

  • If I understood correctly, You can't do it.

    What you can do is store the item in a cookie (cookies are sent with POST requests), OR just use a form.

    ALOT of places use hidden input fields to send information, if you're afraid the data will be tampered with you can use a variaty of hashing techniques to make sure the data is safe, I'll not go into depth here as it's out of the scope of your question but i'll explain further if needed by a comment.

    The problem you're facing is equivalent to sending arguments from A website(ANY WEBSITE), to your controller. Just because the view is generated from your controller, does not mean the controller that catchs the POST request knows where it came from, or what it contains.(that's why we have cookies or POST data)

    Hope it helped.