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


PHP validation类代码示例

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


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

示例1: forgotPwd

function forgotPwd()
{
    global $req;
    global $connection;
    global $module;
    $req->hasParams("email");
    $email = $req->getParam("email");
    $POST = array('email' => $email);
    $val = new validation();
    $val->addSource($POST);
    $val->addRule('email', 'email', true, 2, 100, true);
    $val->run();
    if (sizeof($val->errors) > 0) {
        $connection->close();
        $errors = implode(" <br/> ", $val->errors);
        Res::sendInvalid("Error: " . $errors);
    } else {
        $POST = $val->sanitized;
        $email = $module->escape($POST['email']);
        $output = $module->forgotPwd($email);
        if (is_bool($output)) {
            Res::sendInvalid($module->message);
        } else {
            $res = new Res();
            $res->send();
        }
    }
}
开发者ID:ashutoshSce,项目名称:adminPanel,代码行数:28,代码来源:adminLogin.php

示例2: dologinAction

 public function dologinAction()
 {
     Db::connect();
     $bean = R::dispense('user');
     // the redbean model
     $required = ['Name' => 'name', 'Email' => 'email', 'User_Name' => ['rmnl', 'az_lower'], 'Password' => 'password_hash'];
     \RedBeanFVM\RedBeanFVM::registerAutoloader();
     // for future use
     $fvm = \RedBeanFVM\RedBeanFVM::getInstance();
     $fvm->generate_model($bean, $required);
     //the magic
     R::store($bean);
     $val = new validation();
     $val->addSource($_POST)->addRule('email', 'email', true, 1, 255, true)->addRule('password', 'string', true, 10, 150, false);
     $val->run();
     if (count($val->errors)) {
         Debug::r($val->errors);
         foreach ($val->errors as $error) {
             Notification::setMessage($error, Notification::TYPE_ERROR);
         }
         $this->redirect(Request::createUrl('login', 'login'));
     } else {
         Notification::setMessage("Welcome back !", Notification::TYPE_SUCCESS);
         Debug::r($val->sanitized);
         session::set('user', ['sanil']);
         $this->redirect(Request::createUrl('index', 'index'));
     }
 }
开发者ID:santonil2004,项目名称:ovc,代码行数:28,代码来源:loginController.php

示例3: _validate

 public function _validate($data, $rules_array = array())
 {
     $val = new validation();
     $val->addSource($data);
     $val->AddRules($rules_array);
     $val->run();
     // exit();
     if (sizeof($val->errors) > 0) {
         $this->valid = false;
         return $val->errors;
     } else {
         $this->valid = true;
         return $val->sanitized;
     }
 }
开发者ID:pqzada,项目名称:wp-test,代码行数:15,代码来源:Model.php

示例4: validate

 public static function validate()
 {
     $val = validation::forge();
     $val->add_field('Cname', 'カレッジ名', 'required');
     $val->add_field('Ckana', 'カレッジ名(カナ)', 'required');
     return $val;
 }
开发者ID:nihonLoomba,项目名称:noteshare-,代码行数:7,代码来源:college.php

示例5: validation

 /**
  * Short description of method instance
  *
  * @access public
  * @author Jean-Francois Levesque, <jf.levesque@step.polymtl.ca>
  * @return void
  */
 public static function &instance()
 {
     if (!validation::$instance) {
         validation::$instance = new validation();
     }
     return validation::$instance;
 }
开发者ID:Gwagz,项目名称:stationnement_aep,代码行数:14,代码来源:class.validation.php

示例6: validate

 public static function validate()
 {
     $val = validation::forge();
     $val->add_field('college', 'College', 'required');
     $val->add_field('Did', 'Depart(略称)', 'required');
     $val->add_field('Dname', 'Depart', 'required');
     $val->add_field('Dkana', 'Depart(カナ)', 'required');
     return $val;
 }
开发者ID:nihonLoomba,项目名称:noteshare-,代码行数:9,代码来源:galtuka.php

示例7: validate

 public static function validate()
 {
     $val = validation::forge();
     //バリデーションフィールドの追加
     $val->add_field('cla', 'クラス', 'required|max_length[20]');
     $val->add_field('title', 'タイトル', 'required');
     $val->add_field('Pcontent', '内容', 'required|max_length[200]');
     return $val;
 }
开发者ID:nihonLoomba,项目名称:noteshare-,代码行数:9,代码来源:post.php

示例8: validate

 public static function validate()
 {
     $val = validation::forge();
     //バリデーションフィールドの追加
     $val->add_field('username', 'ユーザID', 'required|max_length[9]');
     $val->add_field('name', 'ユーザ名', 'required|max_length[50]');
     $val->add_field('password', 'パスワード', 'required|min_length[4]|max_length[20]');
     $val->add_field('email', 'Eメール', 'required|valid_email');
     $val->add_field('class', 'クラス', 'required');
     return $val;
 }
开发者ID:nihonLoomba,项目名称:noteshare-,代码行数:11,代码来源:users.php

示例9: validate_admin

 public static function validate_admin()
 {
     if (isset($_POST['submit'])) {
         $required_fields = array("username", "password");
         validation::validate_presentces($required_fields);
         $fields_with_max_lengths = array("password" => 30);
         validation::validate_max_lengths($fields_with_max_lengths);
         return empty(validation::$errors) ? true : false;
     } else {
         return false;
     }
 }
开发者ID:vincentywang,项目名称:simplenote,代码行数:12,代码来源:class.admin.inc.php

示例10: addUsers

function addUsers()
{
    global $req;
    global $connection;
    $req->hasParams("adminUName", "adminFName", "adminGender", "adminEMail", "adminPassword", "adminPhone");
    $adminUName = $req->getParam("adminUName");
    $adminFName = $req->getParam("adminFName");
    $adminGender = $req->getParam("adminGender");
    $adminEMail = $req->getParam("adminEMail");
    $adminPassword = $req->getParam("adminPassword");
    $adminPhone = $req->getParam("adminPhone");
    $POST = array('adminUName' => $adminUName, 'adminFName' => $adminFName, 'adminGender' => $adminGender, 'adminEMail' => $adminEMail, 'adminPassword' => $adminPassword, 'adminPhone' => $adminPhone);
    $genderValues = array('m', 'f', 'u');
    $val = new validation();
    $val->addSource($POST);
    $val->addRule('adminUName', 'string', true, 2, 50, true)->addRule('adminFName', 'string', true, 2, 50, true)->addRule('adminGender', 'string', true, 1, 1, true)->addRule('adminEMail', 'email', true, 5, 100, true)->addRule('adminPassword', 'string', true, 4, 35, true)->addRule('adminPhone', 'string', true, 4, 20, true);
    $val->run();
    if (sizeof($val->errors) > 0) {
        $errors = implode(" <br/> ", $val->errors);
        Res::sendInvalid("Errors:" . $errors);
    } else {
        $POST = $val->sanitized;
        $adminTable = new adminTable($connection);
        $adminUName = $adminTable->escape($POST['adminUName']);
        $adminFName = $adminTable->escape($POST['adminFName']);
        $adminGender = $adminTable->escape($POST['adminGender']);
        $adminEMail = $adminTable->escape($POST['adminEMail']);
        $adminPassword = $adminTable->escape($POST['adminPassword']);
        $adminPhone = $adminTable->escape($POST['adminPhone']);
        $adminId = $adminTable->insertUsers($adminUName, $adminFName, $adminGender, $adminEMail, $adminPassword, $adminPhone);
        if (is_bool($adminId)) {
            Res::sendInvalid("Errors:" . $adminTable->message);
        } else {
            $res = new Res();
            $res->addData("adminId", $adminId);
            $res->send();
        }
    }
}
开发者ID:ashutoshSce,项目名称:adminPanel,代码行数:39,代码来源:adminDashboard.php

示例11: login

 function login($user, $pwd, $rem)
 {
     global $adminSession;
     global $adminCookieUser;
     global $adminCookiePassword;
     global $invalidUserIdOrPassword;
     $POST = array('user' => $user, 'pwd' => $pwd, 'rem' => $rem);
     $val = new validation();
     $val->addSource($POST);
     $val->addRule('user', 'string', true, 1, 35, true)->addRule('pwd', 'string', true, 1, 35, true)->addRule('rem', 'bool');
     $val->run();
     if (sizeof($val->errors) > 0) {
         $connection->close();
         $errors = implode(" <br/> ", $val->errors);
         return "Error: " . $errors;
     } else {
         $POST = $val->sanitized;
         $user = $this->escape($POST['user']);
         $pwd = $this->escape($POST['pwd']);
         $rem = $this->escape($POST['rem']);
         $adminTable = new adminTable($this->connection);
         $result = $adminTable->verifyAdminLogin($user, $pwd);
         if (is_bool($result)) {
             return $invalidUserIdOrPassword;
         } else {
             if (!isset($_SESSION)) {
                 session_start();
             }
             $_SESSION[$adminSession] = $result;
             if ($rem) {
                 setcookie($adminCookieUser, $user, time() + 10 * 365 * 24 * 60 * 60, "/");
                 setcookie($adminCookiePassword, $pwd, time() + 10 * 365 * 24 * 60 * 60, "/");
             }
             return true;
         }
     }
 }
开发者ID:ashutoshSce,项目名称:adminPanel,代码行数:37,代码来源:adminLogin.php

示例12: edit_page

 /**
  * edit page according the passed page id
  * @param string $page_id
  * update session message
  */
 public static function edit_page($page_id)
 {
     global $dbo;
     if (isset($_POST['submit'])) {
         // validations
         $required_fields = array("menu_name", "position", "visible", "content");
         validation::validate_presentces($required_fields);
         $fields_with_max_lengths = array("menu_name" => 200, "description" => 500, "content" => 2000);
         validation::validate_max_lengths($fields_with_max_lengths);
         if (empty(validation::$errors)) {
             // process form perform update
             $id = $page_id;
             $subject_id = (int) $_POST["belong_subject"];
             $menu_name = $dbo->mysql_prep($_POST["menu_name"]);
             // Escape all strings
             $position = (int) $_POST["position"];
             $visible = (int) $_POST["visible"];
             $home_page = (int) $_POST["home_display"];
             $archive = (int) $_POST["archive_display"];
             $description = $dbo->mysql_prep($_POST["description"]);
             //$content = str_replace("&nbsp", "", );
             $content = $dbo->mysql_prep($_POST["content"]);
             // perform database query
             $query = "UPDATE pages SET ";
             $query .= "subject_id = '{$subject_id}', ";
             $query .= "menu_name = '{$menu_name}', ";
             $query .= "position = {$position}, ";
             $query .= "visible = {$visible}, ";
             $query .= "home_page = {$home_page}, ";
             $query .= "archive = {$archive}, ";
             $query .= "description = '{$description}', ";
             $query .= "content = '{$content}' ";
             $query .= "WHERE id = {$id}";
             $query .= " LIMIT 1";
             $result = self::find_by_sql($query);
         }
         if (isset($result) && $dbo->affected_rows($result) >= 0) {
             // success
             $_SESSION["message"] = "Page Updated.";
             utility::redirect_to("manage_content.php?page={$id}");
         } else {
             // failure
             $_SESSION["message"] = "Page update failed.";
         }
     } else {
         // This is probably a GET request
     }
 }
开发者ID:vincentywang,项目名称:simplenote,代码行数:53,代码来源:class.page.inc.php

示例13: create_comment

 /**
  * Create a comment
  * no return value, update $_SESSION message
  */
 public static function create_comment()
 {
     global $dbo;
     global $current_page;
     if (isset($_POST['submit'])) {
         // validations
         $required_fields = array("author", "body");
         validation::validate_presentces($required_fields);
         $fields_with_max_lengths = array("body" => 200);
         validation::validate_max_lengths($fields_with_max_lengths);
         if (empty(validation::$errors)) {
             // process form
             $page_id = $current_page['id'];
             $created = strftime("%Y-%m-%d %H-%M-%S", time());
             //	$created = time();	// store time stam or string
             $author = $dbo->mysql_prep($_POST["author"]);
             $body = $dbo->mysql_prep($_POST["body"]);
             // perform database query
             $query = "INSERT INTO comments (";
             $query .= " page_id, created, author, body";
             $query .= ") VALUES (";
             $query .= " {$page_id}, '{$created}', '{$author}', '{$body}'";
             $query .= ")";
             $result = $dbo->query($query);
             $dbo->confirm_query($result);
         }
         if (isset($result) && $dbo->affected_rows($result) >= 0) {
             // success
             $_SESSION["message"] = "comment created.";
             //utility::redirect_to("manage_admins.php");
         } else {
             // failure
             $_SESSION["message"] = "comment creation failed.";
         }
     } else {
         $_SESSION["message"] = "There is some problem.";
         // not a post submit
     }
 }
开发者ID:vincentywang,项目名称:simplenote,代码行数:43,代码来源:class.comment.inc.php

示例14: edit_subject

 /**
  * edit subject according to form submit
  * @param string $subject_id A field provide by user click edit button
  * 
  */
 public static function edit_subject($subject_id)
 {
     global $dbo;
     if (isset($_POST['submit'])) {
         // validations
         $required_fields = array("menu_name", "position", "visible");
         validation::validate_presentces($required_fields);
         $fields_with_max_lengths = array("menu_name" => 30);
         validation::validate_max_lengths($fields_with_max_lengths);
         if (empty(validation::$errors)) {
             // process form perform update
             $id = $subject_id;
             $menu_name = $dbo->mysql_prep($_POST["menu_name"]);
             // Escape all strings
             $position = (int) $_POST["position"];
             $visible = (int) $_POST["visible"];
             // perform database query
             $query = "UPDATE subjects SET ";
             $query .= "menu_name = '{$menu_name}', ";
             $query .= "position = {$position}, ";
             $query .= "visible = {$visible} ";
             $query .= "WHERE id = {$id}";
             $query .= " LIMIT 1";
             $result = $dbo->query($query);
         }
         if (isset($result) && $dbo->affected_rows($result) >= 0) {
             // success
             $_SESSION["message"] = "Subject Updated.";
             utility::redirect_to("manage_content.php");
         } else {
             // failure
             $_SESSION["message"] = "Subject updit failed.";
         }
     } else {
         // This is probably a GET request
     }
     // end: if(isset($_POST['submit']))
 }
开发者ID:vincentywang,项目名称:simplenote,代码行数:43,代码来源:class.subject.inc.php

示例15: Course

                 if ($users) {
                     $managerCourse->add(new Course(array('name' => $v1->sanitized['name'], 'description' => $v1->sanitized['desc'], 'pictureId' => isset($v1->sanitized['pictureId']) ? $v1->sanitized['pictureId'] : '', 'categories' => $cats, 'authors' => $users)));
                 } else {
                     $error_course_add = $tr->__("Please select at least one author");
                 }
             } else {
                 $error_course_add = $tr->__("Please select at least one category");
             }
         }
     } else {
         $error_course_add = $tr->__("Please select a category");
     }
 }
 if (isset($_POST['remove'])) {
     if (isset($_POST['id']) && !empty($_POST['id'])) {
         $v1 = new validation();
         $rules = array();
         $v1->addSource($_POST['id']);
         for ($i = 0; $i < count($_POST['id']); ++$i) {
             $rules[] = array('type' => 'numeric', "required" => true, 'min' => '0', 'max' => '10000', 'trim' => true);
         }
         $v1->AddRules($rules);
         $v1->run();
         foreach ($v1->sanitized as $id) {
             if ($managerCourse->hasActivities($id)) {
                 $v1->errors['HasLesson'] = $tr->__('The course you want to remove is attached to one or more lessons. Please, first delete these lessons');
                 break;
             }
         }
         if (sizeof($v1->errors) > 0) {
             $error_course_remove = $v1->getMessageErrors();
开发者ID:Cossumo,项目名称:studypress,代码行数:31,代码来源:course.controller.php


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