我想知道下面的表单验证是否可行。我的语法似乎没问题。如果有可能我怎么让它返回false并退出函数(或回去再次输入代码)...顺便说一句我不是PHP程序员....
$this->form_validation->set_rules('customer', lang("customer"), 'trim|required');
这是我需要的验证,所以如果返回false,它将转义函数,并给出错误消息
$this->form_validation->set_rules($id = mysql_real_escape_string($this->input->get('id')),
$pincode = intval($this->input->post('spos_note')),
$result = mysql_query("SELECT `cf1` FROM tec_customers WHERE id='$customer_id' AND cf1 = $pincode") or die(mysql_error()),
'if (mysql_num_rows($result) > 0))');
如果验证正常,则应继续......
if ($this->form_validation->run() == true) {
$quantity = "quantity";
$product = "product";
$unit_cost = "unit_cost";
$tax_rate = "tax_rate";
$date = date('Y-m-d H:i:s');
$customer_id = $this->input->post('customer_id');
$customer_details = $this->pos_model->getCustomerByID($customer_id);
$customer = $customer_details->name;
$note = $this->tec->clear_tags($this->input->post('spos_note'));
$total = 0;
$product_tax = 0;
$order_tax = 0;
$product_discount = 0;
$order_discount = 0;
$percentage = '%';
$i = isset($_POST['product_id']) ? sizeof($_POST['product_id']) : 0;
for ($r = 0; $r < $i; $r++) {
$item_id = $_POST['product_id'][$r];
$real_unit_price = $this->tec->formatDecimal($_POST['real_unit_price'][$r]);
$item_quantity = $_POST['quantity'][$r];
$item_discount = isset($_POST['product_discount'][$r]) ? $_POST['product_discount'][$r] : '0';