简体   繁体   English

Codeigniter表单验证未提交表单且没有错误

[英]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. 提交表单后,表单重新加载并显示“错误”,但没有来自validation_errors函数的其他输出。 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 $ this-> form_validation-> run()== FALSE

but I can not see any condition for when the form validation returns TRUE. 但是当表单验证返回TRUE时,我看不到任何条件。 Try adding a condition when 尝试添加条件时

$this->form_validation->run() == TRUE $ 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!.';
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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