使用codeigniter重新接收,我可以把它放在视图中..但无法验证它

时间:2011-11-11 14:52:33

标签: php codeigniter recaptcha

我正在尝试使用CodeIgniter的recaptcha。我遵循了一些在线说明,最后我只完成了一步,只是将recaptcha传递给视图,但我无法验证用户输入。

这是我的控制器:

function download_application()
{
    //load the libraries
    $this->load->library('form_validation');
    $this->load->library('recaptcha');
    $this->lang->load('recaptcha');     
    //common data
    $data['title'] = $_POST['application_name'];
    $data['header'] = $_POST['application_name'];
    $data['sub_header'] = 'تحميل استمارة قبول المشروع';      
    $data['title'] = $_POST['application_name'];
    $data['recaptcha'] = $this->recaptcha->get_html();      
    //form validation
    $this->form_validation->set_error_delimiters('<span class="notification">', '</span>');
    $this->form_validation->set_message('required', 'هذا الحقل مطلوب ولا يمكن تجاهله');
    $this->form_validation->set_rules('name', 'لابد من ادخال اسمك بالكامل', 'required');
    $this->form_validation->set_rules('email', 'لابد من ادخال بريدك الالكترونى', 'required|email');
    $this->form_validation->set_rules('country', 'لابد من ادخال بلدك', 'required');
    $this->form_validation->set_rules('phone', 'لابد من ادخال رقم تليفونك', 'required');

    //form submitted
    if($this->input->post('recaptchasubmit')){
        if($this->form_validation->run() == FALSE) 
        {

            $this->load->view('header', $data);
            $this->load->view('download', $data);
            $this->load->view('footer', $data); 


        }
        else
        {

            $this->load->view('header', $data);
            $this->load->view('download', $data);
            $this->load->view('footer', $data); 

        }
    }       
    else{

            $this->load->view('header', $data);
            $this->load->view('download', $data);
            $this->load->view('footer', $data); 

    }

}

这是我的观点

<?php 
    $form_attributes = array(
        'class' => 'form'
    );
    $btn_download = array(
        'type'      => 'image',
        'src'        => base_url().'images/download.gif',
        'name'        => 'recaptchasubmit',
        'width'     => '103',
        'height'    => '33',
        'value'        => 'تحميل'
    );
    $name = array(
        'type' => 'text',
        'name' => 'name',
        'id' => 'name',
        'value' => set_value('title')
    );                      
    $email = array(
        'type' => 'text',
        'name' => 'email',
        'id' => 'email',
        'value' => set_value('email')
    );                               
    $country = array(
        'type' => 'text',
        'name' => 'country',
        'id' => 'country',
        'value' => set_value('country')
    );                                  
    $phone = array(
        'type' => 'text',
        'name' => 'phone',
        'id' => 'phone',
        'value' => set_value('phone')
    );   
?>                      
<?php echo form_open($base_url . 'arabia/download_application', $form_attributes); ?>
<fieldset>
    <div class="input_container">
        <label class="required">الاسم بالكامل</label>
        <div class="input"><?php echo form_input($name); ?></div>
        <?php echo form_error('name'); ?>
    </div>
    <div class="input_container">
        <label class="required">البريد الالكترونى</label>
        <div class="input"><?php echo form_input($email); ?></div>
        <?php echo form_error('email'); ?>
    </div>
    <div class="input_container">
        <label class="required">البلد</label>
        <div class="input"><?php echo form_input($country); ?></div>
        <?php echo form_error('country'); ?>
    </div>
    <div class="input_container">
        <label class="required">التليفون</label>
        <div class="input"><?php echo form_input($phone); ?></div>
        <?php echo form_error('phone'); ?>
    </div>
    <?php echo $recaptcha; ?>
    <?php echo form_error('recaptcha_response_field'); ?>

    <?php echo form_hidden('application_name', $title); ?>
    <?php echo form_hidden('generated_id', $title); ?> 
</fieldset>
<span class="download"><?php echo form_submit($btn_download);?></span>                      
<?php echo form_close();?>

0 个答案:

没有答案