Reputation: 3609
How do we clear/reset $this->input->post()
? Probably something analogous to clearing $_POST
?
Upvotes: 0
Views: 9490
Reputation: 2711
Simply call the CI form_validation method.
$this->form_validation->clear_field_data();
Upvotes: 0
Reputation: 994
if it is a must;
create two copies of forms(preferebly in two files in view();
1) every form of type
echo form_input('username','','placeholder="username"').""; let it be
main_form.php
;
2) every form of type
echo form_input('username', set_value('username','username')).""; let it be
sub_form.php
;
redirect all repeated request to second page
whenever you donot want POST values, then call main_form()
[there might be other ways].
Upvotes: 1
Reputation: 485
From the page point of view is better to use ajax-request or after a sucesfully form post to redirect to the same page, so if the user refreshes the page will NOT post the form again.
I think something like this redirect(current_url());
(not sure).
This will clear your post and ensure that user don't accidentally double post the data.
Upvotes: 0