无法从codeigniter </textarea>中的<textarea>发布数据

时间:2013-05-10 01:52:05

标签: codeigniter post textarea

我一直在尝试使用post从textarea中检索这些数据,但我一直没有回复数据。任何帮助将不胜感激。

这是我的表格

  <?php echo validation_errors(); ?>
  <?php echo form_open('s2e/contactValidation'); ?>
     <ul>
         <li><label>Subject<input type="text" id="emailsubject" name="subject" placeholder="example@site.com" width="200"></label></li>
         <li><label>From<input type="email" id="emailfrom" name="from" ></label></li>
         <li><label>Message</label><textarea id="message" name="message" rows="6" cols="200" form="contact" ></textarea></li>
     </ul>
     <button type"submit" name="sendemail">Send</button>   
  </form>

我的控制器看起来像这样

public function contactValidation(){
    $this->load->library('form_validation');
    $this->form_validation->set_error_delimiters('<div id="rerror">', '</div>');


    $this->form_validation->set_rules('subject', 'Subject', 'trim|required|xss_clean');
    $this->form_validation->set_rules('from', 'From', 'trim|required|valid_email');
    $this->form_validation->set_rules('message', 'Message', 'trim|required');

    $subject = $this->input->post('subject');
    $from = $this->input->post('from');
    $message = $this->input->post('message');

    if($this->form_validation->run() == FALSE)
    {
        print_r('failed');
    } else {
        print_r('good');
    }

    var_dump($subject);
    var_dump($from);
    var_dump($message);// this is the culprit that's failing
    }

任何帮助将不胜感激

1 个答案:

答案 0 :(得分:0)

为什么不使用Codeigniter的表单助手:

<?php 
echo validation_errors();
echo form_open('s2e/contactValidation');
echo form_labe('Subject', 'subject');
echo form_input('subject', 'Value Here', 'id="" placeholder=""');
echo form_label('Email', 'email');
echo form_input('email', '', 'attributes=""');
echo form_textarea('msg', '')
echo form_submit('submit', 'Send Form');
echo form_close();
?>