简体   繁体   English

防止重新提交codeigniter的最佳方法

[英]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. 但是我不知道如何在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数组

$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. 我只是混淆使用set_flashdata函数。 Is the right way? 是正确的方法吗?

The above method mentioned you are using is a valid web development design pattern . 您使用的上述方法是有效的Web开发设计模式 Codeigniter is a bit messy for this method but essentially yes it is the right way within Codeigniter. 对于这种方法,Codeigniter有点混乱,但从本质上讲,这是Codeigniter中正确的方法。

Other frameworks such as Laravel support this feature better, allowing you to access old input via Input::old() amongst other methods. Laravel等其他框架则更好地支持此功能,使您可以通过Input::old()等其他方法访问旧输入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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