简体   繁体   中英

Codeigniter Form Validation not submitting form and no errors

I had this form working and to be honest I can not figure out what I might have done. The form will not submit now and I don't see any form validation errors.

controller:

    $this->load->library('form_validation');
    $this->form_validation->set_error_delimiters('<div class="ncerror" >', '</div>');
    $this->form_validation->set_rules('media_consent', 'Media Consent', 'required');
    $this->form_validation->set_rules('aic_name', 'Name', 'required');
    $this->form_validation->set_rules('aic_phone', 'Cell phone', 'required');
    $this->form_validation->set_rules('aic_email', 'Email', 'required');

    if ($this->form_validation->run() == FALSE) {
        $data = $this->ncformdata();
        $this->load->view('templates/sponsorheader', array('title' => 'National Convention Registration'));

        var_export($_POST);
        $this->load->view('ncform', $this->ncformdata());
        $this->load->view('templates/footer2');
    } 

I have

<?php echo "errors" . validation_errors();

at the top of my form. After submitting form, the form reloads with "errors" displayed but no other output from the validation_errors function. Any help with troubleshooting?

should this line

 $this->load->view('ncform', $this->ncformdata());

be this?

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

You have a condition when

$this->form_validation->run() == FALSE

but I can not see any condition for when the form validation returns TRUE. Try adding a condition when

$this->form_validation->run() == TRUE

Example:

 if ($this->form_validation->run() == FALSE) {
        $data = $this->ncformdata();
        $this->load->view('templates/sponsorheader', array('title' => 'National Convention Registration'));
        var_export($_POST);
        $this->load->view('ncform', $this->ncformdata());
        $this->load->view('templates/footer2');

}
else
{ 
        echo 'There are no form validation errors!.';
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM