Welcome Guest, Not a member yet? Register   Sign In
Avoiding POSTDATA popup while still using default Validation class...

Not sure if I'm just doing something wrong or if I'm searching for the wrong thing, but all of the topics I've found don't really seem to solve the problem I'm having.

I'm attempting to use one method for form validation and submission:
function add()
    $data['title'] = "Enter a new component";
    $rules['name'] = "trim|htmlentities|required";
    $fields['name'] = "name";
        //post to db
        $this->session->set_flashdata('flash', 'Item has been added');
        $this->load->view('header', $data);
It works well, however if I refresh the page after the form fails to validate, if I refresh that page I get a POSTDATA pop-up, which makes complete sense. I'm just wondering what the easiest method is to stop this from happening without writing a decent amount of code for each form.

Basically if I want to avoid the error right now I have to redirect and store the form data in a session. However if I were to do that, then I don't see myself being able to use the form validation class...

[eluser]Nikhil Vijayan[/eluser]
The pop up isn't a bug and as u said makes complete sense

Its the basic working of web and there is no reason we should override it ..

if u hate it that much read the rest

To solve your problem u will surely need to use session

using php inbuilt session can help reduce codes like

function add(){

// form validation code

  //submit to db
  $_SESSION['form_name_data'] = $_POST;



and in form page controller

$data = $SESSION[form_name_data];

  $this->load->view('form_page', $data);

in form view page

<input name="first_name" value="<?= $first_name ?>">

etc etc.....

Try Jesse Skinner's approach



Theme © iAndrew 2016 - Forum software by © MyBB