Imran
Imran

Reputation: 3072

best way to preventing form resubmission of codeigniter

Always confused about form resubmission . I know Header and session are the right way. But I don't know how can I proper use in codeigniter. Suppose

For single insert and update query

    $this->db->query(' insert/up query');
    $this->session->set_flashdata('success_message','successfully inserted');
    redirect('my_contoller/home/index');

For pass $data array

$data['pass_data']="some array elements";
$this->session->set_flashdata('pass_data_from_flash_data',$data['pass_data']);
redirect('my_contoller/home/index',$data);

If above technique are right how can I pass query's data for retrieving. Suppose I have a query which return many data. Such as

 $query = $this->db->query(" a query which return large data");
 $data['return_large_result']=$query->result_array(); 

I just confused to using set_flashdata function. Is the right way?

Upvotes: 0

Views: 1824

Answers (1)

SamV
SamV

Reputation: 7586

The above method mentioned you are using is a valid web development design pattern. Codeigniter is a bit messy for this method but essentially yes it is the right way within Codeigniter.

Other frameworks such as Laravel support this feature better, allowing you to access old input via Input::old() amongst other methods.

Upvotes: 1

Related Questions