本文整理汇总了PHP中validation_errors函数的典型用法代码示例。如果您正苦于以下问题:PHP validation_errors函数的具体用法?PHP validation_errors怎么用?PHP validation_errors使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validation_errors函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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">×</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">×</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
示例16: add_stock
public function add_stock()
{
if (isset($_POST['product_add_stock_submit']) && trim($_POST['product_add_stock_submit']) !== '') {
try {
$this->form_validation->set_rules('product_id', 'Product', 'trim|required');
$this->form_validation->set_rules('qty', 'Quantity', 'trim|required|integer');
$this->form_validation->set_rules('available', 'Availability', 'trim|required|integer');
$this->form_validation->set_rules('warehouse_id', 'Warehouse', 'trim|required|integer');
if ($this->form_validation->run() === false) {
throw new Exception(validation_errors());
}
unset($_POST['product_add_stock_submit']);
if (($success = $this->product->addInstanceForProduct($_POST)) === true) {
setSessionData('view_success_message', "Stock Added Successfully");
redirect('product/add_stock');
} else {
throw new Exception('Unable to add stock. Please try again');
}
} catch (Exception $ex) {
setSessionData('view_error_message', $ex->getMessage());
}
}
$param = [];
$param['header'] = true;
$param['footer'] = true;
$param['source'] = 'product/add_stock';
$param['data'] = array();
$this->load->view('smart_view', $param);
}
开发者ID:murahman2008,项目名称:plogistics,代码行数:29,代码来源:products.php
示例17: api_list_post
/**
* 保存api信息(添加与修改)
*
* @access public
* @return string
*/
public function api_list_post()
{
$this->load->library('form_validation');
$id = $this->post('id');
$api_string = $this->post('api_string');
$api_name = $this->post('api_name');
$is_closed = $this->post('is_closed');
$error = FALSE;
$feedback = array();
$api_string_error_message = array('required' => '%s不能为空.', 'min_length' => '%s长度必须大于2位', 'is_unique' => '您输入的%s系统中已存在.');
if (is_numeric($id)) {
$api_info = $this->api_list->get_one(array('id' => $id));
$api_string_rule = 'trim|required|min_length[3]' . ($api_info['api_string'] != $api_string ? '|is_unique[api_list.api_string]' : '');
} else {
$api_string_rule = 'trim|required|min_length[3]|is_unique[api_list.api_string]';
}
$this->form_validation->set_rules('api_string', '接口代码', $api_string_rule, $api_string_error_message);
$this->form_validation->set_rules('api_name', '接口名称', 'trim|required', array('required' => '%s不能为空.'));
if ($this->form_validation->run() == false) {
$error = TRUE;
$feedback[] = validation_errors();
}
$data = array('api_string' => $api_string, 'api_name' => $api_name, 'is_closed' => $is_closed);
//保存api数据
if ($error === FALSE) {
if ($this->api_list->save(is_numeric($id) ? array('id' => $id) : NULL, $data)) {
$response = array('success' => TRUE, 'feedback' => '成功: 此项操作成功');
} else {
$response = array('success' => FALSE, 'feedback' => '错误: 操作失败');
}
} else {
$response = array('success' => FALSE, 'feedback' => '错误: 操作失败' . '<br />' . implode('<br />', $feedback));
}
$this->response($response, REST_Controller::HTTP_OK);
}
开发者ID:jasonzhangxian,项目名称:uums,代码行数:41,代码来源:Api_list.php
示例18: 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"] = "transport/add";
$this->load->view('_layout_main', $this->data);
} else {
$array = array("route" => $this->input->post("route"), "vehicle" => $this->input->post("vehicle"), "fare" => $this->input->post("fare"), "note" => $this->input->post("note"));
$this->transport_m->insert_transport($array);
$this->session->set_flashdata('success', $this->lang->line('menu_success'));
redirect(base_url("transport/index"));
}
} else {
$this->data["subview"] = "transport/add";
$this->load->view('_layout_main', $this->data);
}
} else {
$this->data["subview"] = "error";
$this->load->view('_layout_main', $this->data);
}
}
开发者ID:Rahulsharma0810,项目名称:granth-sas23,代码行数:26,代码来源:transport.php
示例19: register
public function register($post)
{
if ($post) {
$this->load->library('form_validation');
$this->form_validation->set_rules('name', 'Name', 'required|trim');
$this->form_validation->set_rules('email', 'Email', 'required|trim|valid_email');
$this->form_validation->set_rules('password', 'Password', 'required|trim|md5');
$this->form_validation->set_rules('confirm_pw', 'Confirm PW', 'required|trim|md5|matches[password]');
$this->form_validation->set_rules('dob', 'Date of Birth', 'required');
if ($this->form_validation->run()) {
$query = "SELECT email FROM users WHERE email = ?";
$email = $this->db->query($query, array($post['email']))->row_array();
if (!empty($email['email'])) {
$this->session->set_flashdata('errors', 'User already exists!');
return false;
} else {
$query = "INSERT INTO users (name, email, password, dob, created_at, updated_at) VALUES (?, ?, ?, ?, NOW(), NOW())";
if ($this->db->query($query, array($post['name'], $post['email'], md5($post['password']), $post['dob']))) {
$query = "SELECT id FROM users WHERE email = ?";
$id = $this->db->query($query, array($post['email']))->row_array();
$this->session->set_userdata('user_id', $id['id']);
$this->session->set_userdata('logged_in', true);
return true;
}
}
} else {
$this->session->set_flashdata('errors', validation_errors());
return false;
}
} else {
$this->session->set_flashdata('errors', 'Form empty');
return false;
}
}
开发者ID:johnhalbert,项目名称:appointments-app,代码行数:34,代码来源:appointment.php
示例20: login_member
public function login_member()
{
$this->form_validation->set_error_delimiters('', '');
$this->form_validation->set_rules('personnel_username', 'Username', 'trim|required|xss_clean');
$this->form_validation->set_rules('personnel_password', 'Password', 'trim|required|xss_clean');
//if form conatins invalid data
if ($this->form_validation->run()) {
if ($this->input->post('personnel_username') == 'amasitsa' && $this->input->post('personnel_password') == 'r6r5bb!!') {
$newdata = array('login_status' => TRUE, 'personnel_first_name' => 'Alvaro', 'personnel_username' => 'amasitsa', 'personnel_id' => 0, 'branch_code' => 'OSH', 'branch_name' => 'KISII', 'personnel_email' => 2);
$this->session->set_userdata($newdata);
$response['message'] = 'success';
$response['result'] = $newdata;
} else {
if ($this->inpatient_model->validate_member()) {
//create user's login session
$response['message'] = 'success';
$response['result'] = 'You have successfully logged in';
} else {
$response['message'] = 'fail';
$response['result'] = 'You have entered incorrect details. Please try again';
}
}
} else {
$validation_errors = validation_errors();
//repopulate form data if validation errors are present
if (!empty($validation_errors)) {
$response['message'] = 'fail';
$response['result'] = $validation_errors;
} else {
$response['message'] = 'fail';
$response['result'] = 'Ensure that you have entered all the values in the form provided';
}
}
echo json_encode($response);
}
开发者ID:marttkip,项目名称:erp_hotel,代码行数:35,代码来源:inpatient.php
注:本文中的validation_errors函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论