【问题标题】:validation false, although the data is filled验证假,虽然数据已填充
【发布时间】:2013-08-23 19:11:49
【问题描述】:

我有这样的表单验证:

function insert() {

    $this->form_validation->set_message('required', '*column must be filled');
    $this->form_validation->set_rules('judul', 'Judul', 'required');
    $this->form_validation->set_rules('isi', 'Isi', 'required');


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

      $this->layout->addJs('ckeditor/ckeditor.js');
      $this->layout->addJs('js/admin/b267648789c30a07b0efa5bce7bdd9fe.js');
      $this->layout->view('admin/admin_view/insertAdmin_view');
    } else {

      $data = array(
          'title' => $this->input->post('judul'),
          'content' => $this->input->post('isi'),
      );
      $this->db->insert('newses', $data);

       ... other proses ...
              }
  }

虽然我在表单添加数据中填写了数据(我使用 ckeditor 来添加数据),但条件始终为 false,因此它没有添加我想要的数据。但它有错误'如果我添加一些 html 数据,但如果我添加普通数据文本它工作得很好'。再次,当我在 localhost xampp 中运行我的程序时,一切正常,但是当我使用托管时会发生这种情况。 有什么建议吗? 谢谢大家的建议。

【问题讨论】:

  • 你得到的是 ckeditor 值的 post 值(ckeditor 中的文本)吗?
  • 但我认为这不是问题,因为它在 localhost 中运行良好。 ckeditor 的其他配置是否在主机中?
  • 请提及代码在本地主机中运行,而不是在实时服务器上运行...检查您是否在实时服务器上获得 ckeditor 值。
  • 上面的代码在 localhost 中有效,但在服务器中无效。如果我只添加普通文本,例如:“

    Hallo,或其他

    ”,它虽然在 localhost 或服务器中有效,但如果我发布一些类似:“像这样”。它只适用于本地主机。
  • 我应该如何检查服务器上的值ckeditor?

标签: php codeigniter validation ckeditor hosting


【解决方案1】:

打印验证错误

function insert() {

$this->form_validation->set_message('required', '*column must be filled');
$this->form_validation->set_rules('judul', 'Judul', 'required');
$this->form_validation->set_rules('isi', 'Isi', 'required');
//echo validation_errors();
echo $this->input->post('judul')."<br>";
echo $this->input->post('isi');

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

  $this->layout->addJs('ckeditor/ckeditor.js');
  $this->layout->addJs('js/admin/b267648789c30a07b0efa5bce7bdd9fe.js');
  $this->layout->view('admin/admin_view/insertAdmin_view');
} else {

  $data = array(
      'title' => $this->input->post('judul'),
      'content' => $this->input->post('isi'),
  );
  $this->db->insert('newses', $data);

   ... other proses ...
          }
   }

【讨论】:

  • 不工作,我得到 'Denied access to web pages' 。如果你把'退出;'在'回显验证错误()之后;'这意味着你停止程序直到那里,所以页面不会被加载,不是吗?
  • exit 仅表示您想在这一点停止或检查执行到该点...
  • 尝试不退出...它会在顶部打印错误..让我知道
猜你喜欢
  • 2020-07-23
  • 2011-12-17
  • 1970-01-01
  • 2021-06-16
  • 1970-01-01
  • 1970-01-01
  • 2020-11-12
  • 2021-08-09
  • 2017-11-12
相关资源
最近更新 更多