當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DataValidator::getData方法代碼示例

本文整理匯總了PHP中DataValidator::getData方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataValidator::getData方法的具體用法?PHP DataValidator::getData怎麽用?PHP DataValidator::getData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DataValidator的用法示例。


在下文中一共展示了DataValidator::getData方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: array

include_once ROOT_DIR . '/database/dbUserProfile.php';
include_once ROOT_DIR . '/core/class/FormHelper.php';
include_once ROOT_DIR . '/core/class/DataValidator.php';
$errors = array();
$messages = array();
$data = array();
$userCategories = array('admin' => 'RMH Administrator', 'rmhstaff' => 'RMH Staff Approver', 'socialworker' => 'Social Worker');
$userType = 'socialworker';
//default user type
if (isset($_POST['form_token'])) {
    $userType = sanitize($_POST['userGroup']);
    try {
        //form validation rules. should have all the fields included
        $addUserValidationRules = array('userGroup' => array('notempty'), 'title' => array('alpha', 'allow' => array('.')), 'fname' => array('alpha'), 'lname' => array('alpha'), 'phone' => array('number', 'allow' => array('-', '(', ')', '.')), 'username' => array('alphanumeric'), 'email' => array('email'), 'hospital' => array('notempty'), 'notify' => array('notempty'), 'submit' => array('ignore'));
        $validator = new DataValidator($_POST, $addUserValidationRules);
        $data = $validator->getData();
        if ($validator->isValid()) {
            //the validation was successful, perform required operation here below.
            $userType = $data['userGroup'];
            $title = $data['title'];
            $username = $data['username'];
            if (retrieve_UserByAuth($username)) {
                //if user already exists, add error message to validation field
                $validator->setError('username', 'Username already exists');
                throw new DuplicateUserException('Username already exists');
            }
            $fname = $data['fname'];
            $lname = $data['lname'];
            $phone = $data['phone'];
            $email = $data['email'];
            //data for social worker, extra info that rmh staff don't have
開發者ID:kumarsivarajan,項目名稱:rmh-roomreservation-maker,代碼行數:31,代碼來源:addUser.php


注:本文中的DataValidator::getData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。