在这方面需要帮助:
这是我的示例代码,
如果发生 preg_match,我想添加一条验证消息:
请。有关更多详细信息,请参阅内联评论..
public function supplier_entry()
{
if (preg_match("/[\'^£@&*...etc.../", $this->input->post('supplier')))
{
//add or pass validation message, ex. $msg = 'Invalid Supplier Name';
// i tried $this->supplier_entry_form($msg); but its not working.
$this->supplier_entry_form();
}else{
$post_data = array(
'supplier_name' =>$this->input->post('supplier'),
'user' => $this->input->post('user'),
'trx_id' =>$this->input->post('trx_id'),
);
$this->load->model('user_model');
$this->load->model('product_model');
$this->product_model->add_new_supplier($post_data);
$user_data['trx'] = 'Supplier Entry';
$user_data['username'] = $this->user_model->user_info();
$trx_data['supplier'] = $this->product_model->get_supplier_list();
$trx_data['msg'] = 'Supplier Posted.';
$this->load->view('header',$user_data);
$this->load->view('item_supplier', $trx_data);
}
}
提前致谢..
public function supplier_entry_form()
{
$this->load->model('user_model');
$this->load->model('product_model');
$user_data['username'] = $this->user_model->user_info();
$user_data['trx'] = 'Supplier Entry';
$trx_data['supplier'] = $this->product_model->get_supplier_list();
$this->load->view('header', $user_data);
$this->load->view('item_supplier', $trx_data);
}