0

I have a form in a page that pass the output data to another page containing another form.

The problem is that when I try to browse the second page, the validation errors of this page are displayed, because it see the POST array from the form in the page 1 and so it doesn't have the same inputs required to pass the validation error, it display the validation message.

Here is the code in the controller of the second form:

function download_application()
{
    //load the libraries
    $this->load->library('form_validation');

    //form validation
    $this->form_validation->set_rules('name', 'name is required', 'required');
    $this->form_validation->set_rules('email', 'email  is required', 'required|valid_email');
    $this->form_validation->set_rules('country', 'country is required', 'required');
    $this->form_validation->set_rules('phone', 'phone is required', 'required');

    if($this->form_validation->run() == FALSE){
        //error in the form
    }else{
        //no error in the form          
    }
}

3 Answers 3

1

i have two solution as logic i didn't write php but by logic 1. u can add value to your button and in the second page check this value if it didn't equal value then u didn't validate it 2. add hidden filed and pass it to check this value in the second page

Sign up to request clarification or add additional context in comments.

Comments

0

Set a variable that will identify the parent form as the poster and based on that variable set or unset the form validation checks for the current form.

Comments

0

You should have each form submit to itself so that the relevant controller handles its own validation. Once validation passes you can redirect the user to the second controller using the redirect() function from the URL helper or header("Location:...");

4 Comments

hmm, how can i make a different between the post of the two forms
I'm trying to use this code if($this->input->post('recaptchasubmit')){ if($this->form_validation->run() == FALSE) { and when do that no validation error appear in the page load or when clicking the submit button
Can you post contoller 1 and the opening form tags of both forms please?
here is the first form <form action="form2.php" method="post"> and here is the second one <form action="confirmation.php" method="post" class="form" id="download"> and the controller 1 is posted above - this controller that runs the second form

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.