maan81
maan81

Reputation: 3609

Clearing $this->input->post()?

How do we clear/reset $this->input->post()? Probably something analogous to clearing $_POST ?

Upvotes: 0

Views: 9490

Answers (4)

Md Masud
Md Masud

Reputation: 2711

Simply call the CI form_validation method.

$this->form_validation->clear_field_data();

Upvotes: 0

jerinisready
jerinisready

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

BG Adrian
BG Adrian

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

Vineet1982
Vineet1982

Reputation: 7918

To clear the post use

unset ($_POST);

Upvotes: 1

Related Questions