简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM