第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Codeigniter - 表單驗(yàn)證運(yùn)行,但不會(huì)在 FALSE 上顯示錯(cuò)誤

Codeigniter - 表單驗(yàn)證運(yùn)行,但不會(huì)在 FALSE 上顯示錯(cuò)誤

PHP
人到中年有點(diǎn)甜 2023-03-04 14:35:13
我遇到了表單驗(yàn)證的情況。對(duì)于如此簡(jiǎn)單的事情,我似乎無(wú)法弄清楚我的問(wèn)題出在哪里,并且我在網(wǎng)上搜索了很長(zhǎng)時(shí)間。如果返回 FALSE ,我的表單留空時(shí)應(yīng)該form_error為每個(gè)字段拋出錯(cuò)誤form_validation。但是,沒(méi)有任何反應(yīng)。當(dāng)表單完全填寫時(shí),它會(huì)很好地插入到數(shù)據(jù)庫(kù)中。我被困住了,我似乎無(wú)法弄清楚解決方案是什么。我的想法是代碼在某處有拼寫錯(cuò)誤或表單設(shè)計(jì)不正確。這是我的控制器:function create_job()    {        // validate each form field        $this->form_validation->set_rules('repair_order', 'Repair Order', 'required');        $this->form_validation->set_rules('first_name', 'First Name', 'trim|required');        $this->form_validation->set_rules('last_name', 'Last Name', 'trim|required');        $this->form_validation->set_rules('phone', 'Phone', 'required');        $this->form_validation->set_rules('vin', 'VIN', 'trim|required');        $this->form_validation->set_rules('year', 'Vehicle Year', 'trim|required|min_length[4]');        $this->form_validation->set_rules('make', 'Vehicle Make', 'required');        $this->form_validation->set_rules('model', 'Vehicle Model', 'required');        $this->form_validation->set_rules('start_date', 'Start Date', 'required');        $this->form_validation->set_rules('promise_date', 'Promise Date', 'required');        $this->form_validation->set_rules('body_hours', 'Body Labor Hours', 'required');        $this->form_validation->set_rules('paint_hours', 'Paint Labor Hours', 'required');        $this->form_validation->set_rules('body_tech', 'Body Technician', 'required');        $this->form_validation->set_rules('paint_tech', 'Paint Technician', 'required');                );                $this->db->insert('jobs', $data);                $this->session->set_flashdata("success", "New job has been successfully created.");                redirect('main');            }            else            {                redirect('jobs/new');            }    }我是 CodeIgniter 的新手,只是想學(xué)習(xí)。如果有人能看到問(wèn)題出在哪里并能指導(dǎo)我找到答案,我將不勝感激。
查看完整描述

1 回答

?
12345678_0001

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超5個(gè)贊

您的重定向不會(huì)傳遞 form_error 消息。您需要加載一個(gè)視圖(您的表單)才能調(diào)用 form_error 使用$this->load->view()


嘗試這個(gè):


function create_job()

{

    // validate each form field

    $this->form_validation->set_rules('repair_order', 'Repair Order', 'required');

    $this->form_validation->set_rules('first_name', 'First Name', 'trim|required');

    $this->form_validation->set_rules('last_name', 'Last Name', 'trim|required');

    $this->form_validation->set_rules('phone', 'Phone', 'required');

    $this->form_validation->set_rules('vin', 'VIN', 'trim|required');

    $this->form_validation->set_rules('year', 'Vehicle Year', 'trim|required|min_length[4]');

    $this->form_validation->set_rules('make', 'Vehicle Make', 'required');

    $this->form_validation->set_rules('model', 'Vehicle Model', 'required');

    $this->form_validation->set_rules('start_date', 'Start Date', 'required');

    $this->form_validation->set_rules('promise_date', 'Promise Date', 'required');

    $this->form_validation->set_rules('body_hours', 'Body Labor Hours', 'required');

    $this->form_validation->set_rules('paint_hours', 'Paint Labor Hours', 'required');

    $this->form_validation->set_rules('body_tech', 'Body Technician', 'required');

    $this->form_validation->set_rules('paint_tech', 'Paint Technician', 'required');


        if($this->form_validation->run())

        {

            $data = array(

            'repair_order'      => $this->input->post('repair_order'),

            'first_name'        => $this->input->post('first_name'),

            'last_name'         => $this->input->post('last_name'),

            'address'           => $this->input->post('address'),

            'city'              => $this->input->post('city'),

            'state'             => $this->input->post('state'),

            'zip_code'          => $this->input->post('zip_code'),

            'phone'             => $this->input->post('phone'),

            'vin'               => $this->input->post('vin'),

            'year'              => $this->input->post('year'),

            'make'              => $this->input->post('make'),

            'model'             => $this->input->post('model'),

            'start_date'        => $this->input->post('start_date'),

            'promise_date'      => $this->input->post('promise_date'),

            'body_hours'        => $this->input->post('body_hours'),

            'paint_hours'       => $this->input->post('paint_hours'),

            'insurance'         => $this->input->post('insurance'),

            'body_tech'         => $this->input->post('body_tech'),

            'paint_tech'        => $this->input->post('paint_tech')

            );

            $this->db->insert('jobs', $data);


            $this->session->set_flashdata("success", "New job has been successfully created.");

            redirect('main');

        }

        else

        {

            $this->load->view('yournewjobform');

        }

}


查看完整回答
反對(duì) 回復(fù) 2023-03-04
  • 1 回答
  • 0 關(guān)注
  • 116 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)