I'm new to PHP and Code Igniter.
My first project involves a screening questionnaire followed by a customized main form. Overall it's working great, however I have an issue I haven't been able to fix in hours of fiddling: If the user presses the back button from the main form to the screener, a resubmit page error generates.
I would like to provide a better user experience, and I've read that the method is Post Redirect Get. I have looked everywhere including this thread and can't figure out how to actually apply this technique to my project.
A vastly simplified version of my code is below. Can someone please help by providing a simple example of how PRG could work in this simple example? (I do not yet have a database. I am validating, but did not include that below for simplicity).
class Fooscreen extends MY_Controller {
function index() {
$this->load->view('header_view');
$this->load->view('fooscreen_view');}
public function process_form() {
$sessiondata = array(
'your_name' => $_POST['your_name']);
$this->session->set_userdata($sessiondata);
redirect('mainform', 303); }}
fooscreen_view looks like this:
echo form_open('fooscreen/process_form');
$attributeslabel = array(
'class' => 'formlabel');
echo form_label ('What is your name', 'your_name', $attributeslabel);
$data = array(
'name' => 'your_name',
'class' => 'regularinputfield',
'value'=>set_value('your_name'));
echo form_input($data);
echo form_submit('Submit', 'Submit');
echo form_close();