当前位置: 首页>>代码示例>>PHP>>正文


PHP validation_errors函数代码示例

本文整理汇总了PHP中validation_errors函数的典型用法代码示例。如果您正苦于以下问题:PHP validation_errors函数的具体用法?PHP validation_errors怎么用?PHP validation_errors使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了validation_errors函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: editar_form

 public function editar_form($cuenta_id = null)
 {
     if ($cuenta_id) {
         $cuenta = Doctrine::getTable('Cuenta')->find($cuenta_id);
     } else {
         $cuenta = new Cuenta();
     }
     $this->form_validation->set_rules('nombre', 'Nombre', 'required|url_title');
     $this->form_validation->set_rules('nombre_largo', 'Nombre largo', 'required');
     $respuesta = new stdClass();
     if ($this->form_validation->run() == true) {
         $cuenta->nombre = $this->input->post('nombre');
         $cuenta->nombre_largo = $this->input->post('nombre_largo');
         $cuenta->mensaje = $this->input->post('mensaje');
         $cuenta->logo = $this->input->post('logo');
         $cuenta->save();
         $this->session->set_flashdata('message', 'Cuenta guardada con éxito.');
         $respuesta->validacion = true;
         $respuesta->redirect = site_url('manager/cuentas');
     } else {
         $respuesta->validacion = false;
         $respuesta->errores = validation_errors();
     }
     echo json_encode($respuesta);
 }
开发者ID:chileindica,项目名称:SIMPLE,代码行数:25,代码来源:cuentas.php

示例2: index

 public function index()
 {
     $input = null;
     $output = null;
     $clear_form = (bool) $this->input->post('test_form_clear');
     $is_example = (bool) $this->input->post('test_form_example');
     if ($clear_form) {
         // Do nothing, all has been already initialized.
     } elseif ($is_example) {
         $input = @file_get_contents($this->load->path('test.json'));
         try {
             $output = $this->parser->parse_string($input, null, true, 'jsonmin');
         } catch (Exception $e) {
             $output = $e->getMessage();
         }
     } else {
         $validation_rules = array(array('field' => 'input', 'label' => 'Input JSON source', 'rules' => 'trim'));
         $this->form_validation->set_rules($validation_rules);
         if ($this->form_validation->run()) {
             $input = $this->input->post('input');
             try {
                 $output = $this->parser->parse_string($input, null, true, 'jsonmin');
             } catch (Exception $e) {
                 $output = $e->getMessage();
             }
         } elseif (validation_errors()) {
             $output = null;
             $this->template->set('error_message', '<ul>' . validation_errors('<li>', '</li>') . '</ul>');
             $this->template->set('validation_errors', validation_errors_array());
         }
     }
     $this->template->set('clear_form', $clear_form)->set('is_example', $is_example)->set('input', $input)->set('output', $output)->enable_parser_body('i18n')->build('jsonmin');
 }
开发者ID:Qnatz,项目名称:starter-public-edition-4,代码行数:33,代码来源:Jsonmin_controller.php

示例3: add_new_section

 public function add_new_section()
 {
     $this->load->model('mission_section_model', 'MissionSectionModel');
     $data = array();
     //set validation rules
     $this->form_validation->set_rules('title', 'title', 'required|min_length[5]|max_length[250]');
     //$this->form_validation->set_rules('stitle','Small title','required|min_length[5]|max_length[250]');
     $this->form_validation->set_rules('paragraph-sec', 'paragraph', 'required|min_length[5]');
     //run validation
     if ($this->form_validation->run() == FALSE) {
         $this->session->set_flashdata('errors-section', validation_errors());
         redirect(base_url() . 'mission');
     } else {
         // Upload handling
         $config['upload_path'] = 'uploads/';
         $config['allowed_types'] = 'jpg|png';
         $config['max_size'] = '5000';
         $this->load->library('upload', $config);
         $field_name = 'sectionimg';
         if ($this->upload->do_upload($field_name) == FALSE) {
             $this->session->set_flashdata('errors-section', $this->upload->display_errors());
             redirect(base_url() . 'mission');
         } else {
             $file_data = $this->upload->data();
             $row = array('title' => $this->input->post('title'), 'img' => $file_data['file_name'], 'topic' => $this->input->post('paragraph-sec'), 't_small' => $this->input->post('stitle'));
             $this->MissionSectionModel->add_new_section($row);
             $this->session->set_flashdata('success-section', "Section added successfully");
             redirect(base_url() . 'mission');
         }
     }
 }
开发者ID:Omar-Faramawi,项目名称:codeigniter-lppf-project,代码行数:31,代码来源:mission.php

示例4: set

 /**
  * 设置公司信息
  * @param  string  $logo           公司logo
  * @param  string  $company_name   公司名称
  * @param  string  $company_intro  公司简介
  * @return json
  */
 public function set()
 {
     $company_name = $this->input->get_post('company_name', TRUE);
     $company_intro = $this->input->get_post('company_intro', TRUE);
     if ($this->form_validation->run() == FALSE) {
         $error = validation_errors();
         $this->to_api_message(0, $error);
     }
     $data = array();
     if ($company_name) {
         $data['name'] = $company_name;
     }
     if ($company_intro) {
         $data['intro'] = $company_intro;
     }
     $company = $this->company->get();
     if (empty($company)) {
         $affected = $this->company->insert($data);
     } else {
         $affected = $this->company->update($data);
     }
     $op_description = sprintf("设置了企业信息:%s", $company_name);
     if ($affected) {
         $this->add_op_log($op_description, 1);
         $this->to_api_message(1, 'update_company_info_success');
     } else {
         $this->add_op_log($op_description, 0);
         $this->to_api_message(0, 'update_company_info_failed');
     }
 }
开发者ID:alswl,项目名称:secken-private,代码行数:37,代码来源:Company.php

示例5: editar

 function editar($id = null)
 {
     // Array de dados para a view
     $dados = array();
     // Obtém os dados
     if ($id) {
         // se não tem post e tem id, obtém da base de dados
         $dados['estado'] = $estado_old = $this->Estados_model->obter($id);
     }
     // Se tem post, salva os dados
     if ($this->input->post('submit')) {
         // Se existe procede, se não exibe erro!
         $dados = $this->input->post();
         // Validação
         $this->form_validation->set_rules('estado[nome]', 'Nome', 'trim|required');
         if ($this->form_validation->run()) {
             if ($this->Estados_model->salvar($dados['estado']) > 0) {
                 redirect('site/estados/listar');
             } else {
                 $dados['erro'] = 'Não foi possível salvar o registro.';
             }
         } else {
             $dados['erro'] = validation_errors();
         }
     }
     $dados['paises'] = array();
     $paises = $this->Paises_model->listar();
     foreach ($paises as $pais) {
         $dados['paises'][$pais['id']] = $pais['nome'];
     }
     $this->load->view('estados_editar', $dados);
 }
开发者ID:NaszvadiG,项目名称:DivaSul,代码行数:32,代码来源:estados.php

示例6: index

 function index()
 {
     $this->load->library('form_validation');
     $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
     $this->form_validation->set_rules('sifre', 'Sifre', 'required|min_length[5]|max_length[12]');
     $this->form_validation->set_message('email');
     $data['errors'] = null;
     if ($this->form_validation->run() == FALSE) {
         $data['errors'] = validation_errors();
     } else {
         $email = $this->input->post('email');
         $sifre = $this->input->post('sifre');
         $login = $this->db->where('email', $email)->where('sifre', $sifre)->get('login');
         if ($login->num_rows() > 0) {
             $x = $login->row();
             $bilgiler = array('email' => $x->email, 'sifre' => $x->sifre, 'yetki' => $x->yetki);
             //var_dump($bilgiler);
             $this->session->set_userdata($bilgiler);
             redirect('admin/mainpage', 'refresh');
         } else {
             $data['errors'] = 'Böyle Bir Kullanıcı Bulunamadı';
         }
     }
     $this->load->view('admin/sabit/login', $data);
 }
开发者ID:ahmetgungor,项目名称:adasus,代码行数:25,代码来源:login.php

示例7: index

 /**
  * The index page controller
  */
 function index()
 {
     $target_error = false;
     $data = array();
     $searchtarget = $this->config->item('search');
     $this->form_validation->set_rules('search', 'Search', 'required');
     if (count($searchtarget) == 1) {
         $searchtarget = $searchtarget[key($searchtarget)][0];
     } elseif (!isset($searchtarget[$this->input->post('target')])) {
         $target_error = true;
     } else {
         $searchtarget = $this->input->post('target');
     }
     if ($this->form_validation->run() == FALSE || $target_error) {
         $error = array();
         $validation_error = validation_errors();
         if ($validation_error) {
             $error[] = $validation_error;
         }
         if ($target_error) {
             $error[] = 'Please select a search-target.';
         }
         $data['validation_message'] = $error;
     } else {
         redirect($searchtarget . '/' . urlencode($this->input->post('search')));
     }
     $this->_render_page('search/search', $data);
 }
开发者ID:inexor-game-obsolete,项目名称:project-site,代码行数:31,代码来源:Search.php

示例8: validate_user

 public function validate_user($user)
 {
     $data = array();
     $config = array(array('field' => 'username', 'label' => 'User Name', 'rules' => 'trim|required|valid_email'), array('field' => 'password', 'label' => 'Password', 'rules' => 'trim|required'));
     $this->form_validation->set_rules($config);
     $get_user_with_email = $this->get_user_with_email($user['username']);
     if ($this->form_validation->run() == FALSE) {
         $data["error_message"] = validation_errors();
         $data["is_login"] = FALSE;
     } else {
         if (!$get_user_with_email) {
             $data["error_message"] = "User not found,Please register";
             $data["is_login"] = FALSE;
         } else {
             if ($get_user_with_email['password'] == md5($user['password'])) {
                 $data["is_login"] = TRUE;
                 $data["success_message"] = "Successful log in !";
                 $current_user = array('user_id' => $get_user_with_email['id'], 'user_name' => $get_user_with_email['username'], 'first_name' => $get_user_with_email['first_name'], 'last_name' => $get_user_with_email['last_name']);
                 $this->session->set_userdata("current_user", $current_user);
             } else {
                 $data["error_message"] = "User password does not match";
                 $data["is_login"] = FALSE;
             }
         }
     }
     return $data;
 }
开发者ID:v33lynn,项目名称:BookNook,代码行数:27,代码来源:User.php

示例9: tracking_meal_log

 public function tracking_meal_log()
 {
     $this->common->authenticate();
     $tables = $this->input->post('tables');
     $meal_date = $this->input->post('lunch_date');
     $note = $this->input->post('note');
     $private_note = $this->input->post('private_note');
     $actual_meals = $this->input->post('actual_meals');
     $shift = $this->input->post('shift');
     $this->validation('tracking');
     if ($this->form_validation->run() == FALSE) {
         $errors = validation_errors();
         $data['status'] = 'failure';
         $data['message'] = $errors;
     } else {
         $this->load->model('meals_model');
         $message = $this->common->get_message('gen_log_file_meal', array('gen_log_file_success', 'gen_log_file_failure'));
         if ($this->meals_model->update_meal_log($shift, $tables, $meal_date, $note, $private_note, $actual_meals)) {
             $data = array('status' => 'success', 'message' => $message['gen_log_file_success']);
         } else {
             $data = array('status' => 'failure', 'message' => $message['gen_log_file_failure']);
         }
     }
     echo json_encode($data);
 }
开发者ID:cuongcody,项目名称:angularjs_elunchdemo,代码行数:25,代码来源:Home.php

示例10: modificar

 private function modificar()
 {
     if (isset($_GET['id']) && $this->aviones_model->exist('aviones', array('id_avion' => $_GET['id'], 'status' => 'ac'))) {
         $this->carabiner->css(array(array('general/forms.css', 'screen'), array('general/tables.css', 'screen')));
         $this->carabiner->js(array(array('aviones/frm_addmod.js')));
         $this->configAddAvion();
         if ($this->form_validation->run() == FALSE) {
             $params['frm_errors'] = $this->showMsgs(2, preg_replace("[\n|\r|\n\r]", '', validation_errors()));
         } else {
             $model_resp = $this->aviones_model->editAvion($_GET['id']);
             if ($model_resp[0]) {
                 $params['frm_errors'] = $this->showMsgs(3);
             } else {
                 $params['frm_errors'] = $this->showMsgs(2, 'El avión que desea modificar no existe');
             }
         }
         $params['info_empleado'] = $this->info_empleado['info'];
         $params['opcmenu_active'] = 'Aviones';
         //activa la opcion del menu
         $params['seo']['titulo'] = 'Modificar Avion';
         $params = array_merge($params, $this->aviones_model->getAviones($_GET['id']));
         if (isset($_GET['msg'][0])) {
             $params['frm_errors'] = $this->showMsgs($_GET['msg']);
         }
         $this->load->view('panel/header', $params);
         $this->load->view('panel/general/menu', $params);
         $this->load->view('panel/aviones/modificar', $params);
         $this->load->view('panel/footer', $params);
     } else {
         redirect(base_url('panel/aviones/'));
     }
 }
开发者ID:sujatapadwal,项目名称:diatomeas,代码行数:32,代码来源:aviones.php

示例11: add_semester

 public function add_semester()
 {
     $this->form_validation->set_rules('addsemester', 'Semester', 'trim|required');
     $this->form_validation->set_rules('addyear', 'Year', 'trim|required|greater_than[1997]|less_than[2100]');
     if ($this->form_validation->run() == TRUE) {
         $data = array('semester' => $this->input->post('addsemester'), 'curriculum_year' => $this->input->post('addyear'), 'userid' => $this->session->userdata('userid'));
         $this->load->model('semester_model');
         $this->semester_model->add_semester($data);
         $data = array('current_user' => $this->session->userdata('displayname'), 'current_username' => $this->session->userdata('username'), 'add_sem_error_msg' => NULL, 'add_sem_error_action' => NULL);
         redirect(base_url() . 'index.php/semester', 'refresh');
     } else {
         $add_sem_error_msg = '<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">&times;</button>' . validation_errors() . '</div>';
         $add_sem_error_action = "\$('#modalAddSemester').modal('show');";
         $data = array('current_user' => $this->session->userdata('displayname'), 'current_username' => $this->session->userdata('username'), 'add_sem_error_msg' => $add_sem_error_msg, 'add_sem_error_action' => $add_sem_error_action);
         $this->load->model('semester_model');
         if ($query = $this->semester_model->list_semester()) {
             $data['records'] = $query;
         }
         if (!$data['records']) {
             $add_sem_error_msg = '<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">&times;</button>The record is existing!</div>';
             $add_sem_error_action = "\$('#modalAddSemester').modal('show');";
             $data = array('current_user' => $this->session->userdata('displayname'), 'current_username' => $this->session->userdata('username'), 'add_sem_error_msg' => $add_sem_error_msg, 'add_sem_error_action' => $add_sem_error_action);
         }
         $this->session->set_userdata($data);
         $this->load->view('includes/nocache');
         $this->load->view('includes/header2');
         $this->load->view('semester_view', $data);
         $this->load->view('includes/semester_footer', $data);
     }
 }
开发者ID:viniciusferreira,项目名称:ScheduleBox,代码行数:30,代码来源:semester.php

示例12: edit_post

 public function edit_post()
 {
     $data = $this->data;
     //取得公用數據
     $this->form_validation->set_rules('name_Str', '產品名稱', 'required');
     if ($this->form_validation->run() !== FALSE) {
         //基本post欄位
         $showpieceid_Num = $this->input->post('showpieceid_Num', TRUE);
         $name_Str = $this->input->post('name_Str', TRUE);
         $price_Num = $this->input->post('price_Num', TRUE);
         $synopsis_Str = $this->input->post('synopsis_Str', TRUE);
         $classids_Arr = $this->input->post('classids_Arr', TRUE);
         $content_Str = $this->input->post('content_Str');
         $content_specification_Str = $this->input->post('content_specification_Str');
         $prioritynum_Num = $this->input->post('prioritynum_Num', TRUE);
         $picids_Arr = $this->input->post('picids_Arr', TRUE);
         //建構Showpiece物件,並且更新
         $showpiece_Showpiece = new Showpiece(['showpieceid_Num' => $showpieceid_Num, 'name_Str' => $name_Str, 'price_Num' => $price_Num, 'synopsis_Str' => $synopsis_Str, 'mainpicids_Arr' => $mainpicids_Arr, 'picids_Arr' => $picids_Arr, 'classids_Arr' => $classids_Arr, 'content_Str' => $content_Str, 'content_specification_Str' => $content_specification_Str, 'prioritynum_Num' => $prioritynum_Num]);
         $showpiece_Showpiece->update();
         //送出成功訊息
         $this->load->model('Message');
         $this->Message->show(['message' => '設定成功', 'url' => 'admin/base/showpiece/showpiece/tablelist']);
     } else {
         $validation_errors_Str = validation_errors();
         $validation_errors_Str = !empty($validation_errors_Str) ? $validation_errors_Str : '設定錯誤';
         $this->load->model('Message');
         $this->Message->show(['message' => $validation_errors_Str, 'url' => 'admin/base/showpiece/showpiece/tablelist']);
     }
 }
开发者ID:fansWoo,项目名称:win_the_world,代码行数:29,代码来源:Showpiece.php

示例13: AddPayNotification

 public function AddPayNotification()
 {
     $this->load->library('form_validation');
     $orderId = $this->input->post('orderId');
     $account = $this->input->post('account');
     $money = $this->input->post('money');
     $memo = $this->input->post('memo', TRUE);
     $payDatetime = $this->input->post('payDatetime');
     $payWay = $this->input->post('payWay');
     $this->form_validation->set_rules('orderId', '訂單編號', 'required|numeric');
     $this->form_validation->set_rules('account', '匯款帳號', 'required|numeric');
     $this->form_validation->set_rules('money', '匯款金額', 'required|numeric');
     $this->form_validation->set_message('required', '%s為必填!');
     $this->form_validation->set_message('numeric', '%s必須為數字!');
     if ($this->form_validation->run() == FALSE) {
         echo validation_errors();
     } else {
         if ($payWay != 'ATM轉帳付款') {
             echo '錯誤發生! payWay=' . $payWay;
         } else {
             $data = array('orderId' => $orderId, 'account' => $account, 'money' => $money, 'payDatetime' => $payDatetime, 'memo' => $memo);
             $error = $this->Order_model->add_pay_notification($data);
             echo $error['code'];
         }
     }
 }
开发者ID:jason82714,项目名称:coffeeline,代码行数:26,代码来源:Order.php

示例14: validar_turnos

 public function validar_turnos()
 {
     $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email|xss_clean');
     $this->form_validation->set_rules('contrasena', 'Contraseña', 'required|trim|min_length[8]|xss_clean');
     if ($this->form_validation->run() == FALSE) {
         echo validation_errors('<span class="error">', '</span>');
     } else {
         $data['email'] = $this->input->post('email');
         $data['contrasena'] = $this->input->post('contrasena');
         $data = $this->security->xss_clean($data);
         $login_check = $this->modelo->check_login($data);
         if ($login_check != FALSE) {
             $usuario_historico = $this->modelo->anadir_historico_acceso($login_check[0]);
             $this->session->set_userdata('session', TRUE);
             $this->session->set_userdata('email', $data['email']);
             if (is_array($login_check)) {
                 foreach ($login_check as $login_element) {
                     $this->session->set_userdata('id', $login_element->id);
                     $this->session->set_userdata('id_perfil', $login_element->id_perfil);
                     $this->session->set_userdata('perfil', $login_element->perfil);
                     $this->session->set_userdata('operacion', $login_element->operacion);
                     $this->session->set_userdata('sala', $login_element->sala);
                     $this->session->set_userdata('coleccion_id_operaciones', $login_element->coleccion_id_operaciones);
                     $this->session->set_userdata('nombre_completo', $login_element->nombre . ' ' . $login_element->apellidos);
                 }
             }
             echo TRUE;
         } else {
             echo '<span class="error">¡Ups! tus datos no son correctos, verificalos e intenta nuevamente por favor.</span>';
         }
     }
 }
开发者ID:estrategasdigitales,项目名称:Alakazam,代码行数:32,代码来源:turnos.php

示例15: add

 public function add()
 {
     $usertype = $this->session->userdata("usertype");
     if ($usertype == "Admin") {
         if ($_POST) {
             $rules = $this->rules();
             $this->form_validation->set_rules($rules);
             if ($this->form_validation->run() == FALSE) {
                 $this->data['form_validation'] = validation_errors();
                 $this->data["subview"] = "exam/add";
                 $this->load->view('_layout_main', $this->data);
             } else {
                 $array = array("termID" => $this->input->post("termID"), "exam" => $this->input->post("exam"), "date" => date("Y-m-d", strtotime($this->input->post("date"))), "note" => $this->input->post("note"));
                 $this->exam_m->insert_exam($array);
                 $this->session->set_flashdata('success', $this->lang->line('menu_success'));
                 redirect(base_url("exam/index"));
             }
         } else {
             $this->data["subview"] = "exam/add";
             $this->load->view('_layout_main', $this->data);
         }
     } else {
         $this->data["subview"] = "error";
         $this->load->view('_layout_main', $this->data);
     }
 }
开发者ID:motoni,项目名称:white,代码行数:26,代码来源:exam.php


注:本文中的validation_errors函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。