1

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();
Community
  • 1
  • 1
Cyclist
  • 111
  • 1
  • 12
  • No answers yet. I'm not sure if my question is too simple, or more difficult than I realize. To clarify further, the problem is that with the code above when the person presses the back button from the main form back to the screener they get an error. In Chrome it says "Form Resubmit." In the other browsers, you can go back from the main form to the screening form but when you press submit again you get a message that says "The action you have requested is not allowed." – Cyclist Jun 19 '16 at 21:44

0 Answers0