How to prevent refresh form page in CodeIgniter?
If I use redirect — all fine, but I can directly appeal to page site.com/update/success.
How can I prevent direct access to success page (only from site.com/update/) ?
Controller update.php
public function index() {
if($this->form_validation->run() == FALSE) {
$data['error'] = 'Something wrong';
$this->load->view('update', $data);
} else {
redirect('/update/success');
}
}
public function success() {
$message = 'Your profile has been successfully updated';
$this->load->view($message);
}
You could set a token in flashdata in your index() function and then check for that token in your success() method.