dongqiao6730 2015-08-10 08:05
浏览 66

Codeigniter自定义数据验证

I will try to upload an Excel file and verify its contents.

So I tried the code as below.

if ($this->upload->do_upload("filename"))
{

    ...

    // I Think it is idiot code . . but . . anyway . . :_(
    $_POST = array(
        "name" => $cell[0],
        "phone" => $cell[1],
        "birth" => $cell[2],
        ...
    );


    $config = array(
        array("field"=>"name", "label"=>"Name", "rule"=> "required"),
        ...
    );

    $this->form_validation->set_rules($config);
    $this->form_validation->set_error_delimiters('', '');

    if ($this->form_validation->run() === false)
    {
        throw new Exception($this->form_validation->error_string());
    }

    ...
}

How to validate custom data using form_validation?

  • 写回答

1条回答 默认 最新

  • dongqie2028 2016-06-07 09:14
    关注

    You can pass your data like that:

    $data = array(
    'username' => 'johndoe',
    'password' => 'mypassword',
    'passconf' => 'mypassword'
    );
    
    $this->form_validation->set_data($data);
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度