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


PHP Validation::add2Errors方法代码示例

本文整理汇总了PHP中Validation::add2Errors方法的典型用法代码示例。如果您正苦于以下问题:PHP Validation::add2Errors方法的具体用法?PHP Validation::add2Errors怎么用?PHP Validation::add2Errors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Validation的用法示例。


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

示例1: Form

<?php

session_start();
if (Login::isLogged(Login::$_login_front)) {
    Helper::redirect(Login::$_dashboard_front);
}
$objForm = new Form();
$objValid = new Validation($objForm);
$objUser = new User();
// login form
if ($objForm->isPost('login_email')) {
    if ($objUser->isUser($objForm->getPost('login_email'), $objForm->getPost('login_password'))) {
        Login::loginFront($objUser->_id, Url::getReferrerUrl());
    } else {
        $objValid->add2Errors('login');
    }
}
// registration form
if ($objForm->isPost('first_name')) {
    $objValid->_expected = array('first_name', 'last_name', 'address_1', 'address_2', 'town', 'county', 'post_code', 'country', 'email', 'password', 'confirm_password');
    $objValid->_required = array('first_name', 'last_name', 'address_1', 'town', 'county', 'post_code', 'country', 'email', 'password', 'confirm_password');
    $objValid->_special = array('email' => 'email');
    $objValid->_post_remove = array('confirm_password');
    $objValid->_post_format = array('password' => 'password');
    // validate password
    $pass_1 = $objForm->getPost('password');
    $pass_2 = $objForm->getPost('confirm_password');
    if (!empty($pass_1) && !empty($pass_2) && $pass_1 != $pass_2) {
        $objValid->add2Errors('password_mismatch');
    }
    $email = $objForm->getPost('email');
开发者ID:huynhv,项目名称:uniguide,代码行数:31,代码来源:login.php

示例2: User

$id = Url::getParam('id');
if (!empty($id)) {
    $objUser = new User();
    $user = $objUser->getUser($id);
    if (!empty($user)) {
        $objForm = new Form();
        $objValid = new Validation($objForm);
        if ($objForm->isPost('first_name')) {
            $objValid->_expected = array('first_name', 'last_name', 'address_1', 'address_2', 'town', 'county', 'post_code', 'country', 'email');
            $objValid->_required = array('first_name', 'last_name', 'address_1', 'town', 'county', 'post_code', 'country', 'email');
            $objValid->_special = array('email' => 'email');
            $email = $objForm->getPost('email');
            $duplicate = $objUser->getByEmail($email);
            if (!empty($duplicate) && $duplicate['id'] != $user['id']) {
                $objValid->add2Errors('email_duplicate');
            }
            if ($objValid->isValid()) {
                if ($objUser->updateUser($objValid->_post, $user['id'])) {
                    Helper::redirect('/admin' . Url::getCurrentUrl(array('action', 'id')) . '&action=edited');
                } else {
                    Helper::redirect('/admin' . Url::getCurrentUrl(array('action', 'id')) . '&action=edited-failed');
                }
            }
        }
        require_once 'template/_header.php';
        ?>
	
	<h1>Clients :: Edit</h1>
	
	<form action="" method="post">
开发者ID:sydorenkovd,项目名称:e-com.loc,代码行数:30,代码来源:edit.php

示例3: Catalogue

<?php

$id = Url::getParam('id');
if (!empty($id)) {
    $objCatalogue = new Catalogue();
    $category = $objCatalogue->getCategory($id);
    if (!empty($category)) {
        $objForm = new Form();
        $objValid = new Validation($objForm);
        if ($objForm->isPost('name')) {
            $objValid->_expected = array('name');
            $objValid->_required = array('name');
            $name = $objForm->getPost('name');
            if ($objCatalogue->duplicateCategory($name, $id)) {
                $objValid->add2Errors('name_duplicate');
            }
            if ($objValid->isValid()) {
                if ($objCatalogue->updateCategory($name, $id)) {
                    Helper::redirect('/admin' . Url::getCurrentUrl(array('action', 'id')) . '&action=edited');
                } else {
                    Helper::redirect('/admin' . Url::getCurrentUrl(array('action', 'id')) . '&action=edited-failed');
                }
            }
        }
        require_once 'template/_header.php';
        ?>
	
	<h1>Categories :: Edit</h1>
	
	<form action="" method="post">
		
开发者ID:sydorenkovd,项目名称:e-com.loc,代码行数:30,代码来源:edit.php

示例4: Page

<?php

$this->addScript('/admin/js/ckeditor/ckeditor.js');
$this->addScript('/admin/js/ckeditor/adapters/jquery.js');
$objPage = new Page($this->objLanguage);
$objForm = new Form($this->objUrl);
$objValidation = new Validation($this->objLanguage);
$expected = array('name', 'content', 'meta_title', 'meta_description', 'meta_keywords', 'identity');
$required = array('name', 'content', 'meta_title', 'meta_description', 'meta_keywords', 'identity');
if (isset($_POST['name'])) {
    $array = $objForm->post2Array($expected, 'content', array('identity' => 'sanitise'));
    if (array_key_exists('identity', $array) && !empty($array['identity']) && $objPage->duplicate($array['identity'])) {
        $objValidation->add2Errors('identity', 'identity_taken');
    }
    if ($objValidation->isValid($array, $required)) {
        if ($objPage->add($array)) {
            Helper::redirect($this->objUrl->getCurrent(array('a', 'id')) . '/a/index');
        }
    }
}
require_once 'header.php';
?>

<h1><?php 
echo $this->objLanguage->labels[9];
?>
</h1>

<form method="post">
	<table class="tbl_insert">
		<tr>
开发者ID:joakinCC,项目名称:udemy.com-Multilingual-CMS-Website-with-PHP-MySQL-jQuery,代码行数:31,代码来源:add.php

示例5: Form

<?php

if (Login::isLogged(Login::$_login_admin)) {
    Helper::redirect(Login::$_dashboard_admin);
}
$objForm = new Form();
$objValid = new Validation($objForm);
if ($objForm->isPost('login_email')) {
    $objAdmin = new Admin();
    if ($objAdmin->isUser($objForm->getPost('login_email'), $objForm->getPost('login_password'))) {
        Login::loginAdmin($objAdmin->_id, Url::getReferrerUrl());
    } else {
        $objValid->add2Errors('login');
    }
}
require_once 'template/_header.php';
?>

<h1>Login</h1>

<form action="" method="post">
	
	<table cellpadding="0" cellspacing="0" border="0" class="tbl_insert">
		
		<tr>
			<th><label for="login_email">Login:</label></th>
			<td>
				<?php 
echo $objValid->validate('login');
?>
				<input type="text" name="login_email" id="login_email"
开发者ID:sydorenkovd,项目名称:e-com.loc,代码行数:31,代码来源:index.php

示例6: Form

<?php

$objForm = new Form();
$objValid = new Validation($objForm);
if ($objForm->isPost('name')) {
    $objValid->_expected = array('name', 'new', 'retype');
    $objValid->_required = array('name', 'new', 'retype');
    $new = $objForm->getPost('new');
    $retype = $objForm->getPost('retype');
    if ($new != '' && $retype != '' && $new != $retype) {
        $objValid->add2Errors('new_mismatch');
    }
    $id = $objForm->getPost('id');
    if ($objValid->isValid()) {
        $encoded = Login::hash($new);
        if ($objMember->updateMember(array('password' => $encoded), $id)) {
            $success = true;
        } else {
            $success = false;
        }
    }
}
require_once '_header.php';
?>
        <h1>Member :: Reset Pasword</h1>
        <?php 
if (!isset($success)) {
    ?>
            <form action="" method="post">
                <table cellpadding="0" cellspacing="0" border="0" class="tbl_insert">
                    <tr>
开发者ID:nguyengiangoc,项目名称:SugarKMS,代码行数:31,代码来源:reset-password.php

示例7: Form

$objForm = new Form();
$objValid = new Validation($objForm);
$objSchool = new School();
$result = null;
$objValid->_expected = array('name', 'gender', 'day', 'month', 'year', 'personal_email', 'phone', 'skype', 'facebook', 'high_school', 'grad_year_h', 'uni', 'grad_year_u');
$objValid->_required = array('name', 'gender', 'personal_email');
//var_dump($objValid->_required);
$objValid->_special = array(array('field' => 'personal_email', 'case_type' => 'check_is_email'));
if ($objForm->isPost('name')) {
    $high_school = $objForm->getPost('high_school');
    $grad_year_h = $objForm->getPost('grad_year_h');
    $uni = $objForm->getPost('uni');
    $grad_year_u = $objForm->getPost('grad_year_u');
    $email = $objForm->getPost('personal_email');
    if (empty($high_school) && !empty($grad_year_h)) {
        $objValid->add2Errors('high_school');
    }
    if (!empty($high_school) && empty($grad_year_h)) {
        $objValid->add2Errors('grad_year_h');
    }
    if (empty($uni) && !empty($grad_year_u)) {
        $objValid->add2Errors('uni');
    }
    if (!empty($uni) && empty($grad_year_u)) {
        $objValid->add2Errors('grad_year_u');
    }
    if ($objMember->isDuplicateEmail($email)) {
        $objValid->add2Errors('duplicate_email');
    }
    $params = $objValid->objForm->getPostArray($objValid->_expected);
    if (!empty($high_school)) {
开发者ID:nguyengiangoc,项目名称:SugarKMS,代码行数:31,代码来源:add.php

示例8: Form

<?php

if (Login::isLogged(Login::$_login_admin_id)) {
    Helper::redirect(SITE_URL . Login::$_dashboard_admin);
}
$objForm = new Form();
$objValidation = new Validation($objForm);
if ($objForm->isPost('login_user')) {
    $objAdmin = new Admin();
    $objValidation->_required = array('login_user', 'login_password');
    if ($objAdmin->isUser($objForm->getPost('login_user'), $objForm->getPost('login_password'))) {
        $result = Login::loginAdmin($objAdmin->_user, Url::getReferrerUrl());
    } else {
        $objValidation->add2Errors('login');
    }
    if ($objValidation->isValid()) {
    }
}
?>

<html>
    <head>
        <title>XBook Management System</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <link href="css/Core.css" rel="stylesheet" type="text/css" />
        
        <link rel="stylesheet" href="../css/bootstrap.min.css">
        <link rel="stylesheet" href="../css/bootstrap-theme.min.css">
        <link rel="stylesheet" href="../css/bootstrap-select.min.css">
开发者ID:brahmantyo,项目名称:xbook,代码行数:31,代码来源:login.php

示例9: Form

if ($this->admin['access'] != 1) {
    Helper::redirect('/panel/content/c/pages/a/index');
}
$id = $this->objUrl->get('id');
if (!empty($id)) {
    $admin = $this->objAdmin->getOne($id);
    if (!empty($admin)) {
        $objForm = new Form($this->objUrl);
        $objValidation = new Validation($this->objLanguage);
        $expected = array('access', 'first_name', 'last_name', 'email', 'password');
        $required = array('access', 'first_name', 'last_name', 'email');
        if (isset($_POST['access'])) {
            $array = $objForm->post2Array($expected);
            if (array_key_exists('email', $array) && !empty($array['email']) && $this->objAdmin->duplicate($array['email'], $id)) {
                $objValidation->add2Errors('email', 'email_taken');
            }
            if ($objValidation->isValid($array, $required)) {
                if ($this->objAdmin->update($array, $admin)) {
                    Helper::redirect($this->objUrl->getCurrent(array('a', 'id')) . '/a/index');
                }
            }
        }
        $access = $this->objAdmin->getAccess();
        require_once 'header.php';
        ?>

<h1><?php 
        echo $this->objLanguage->labels[90];
        ?>
</h1>
开发者ID:joakinCC,项目名称:udemy.com-Multilingual-CMS-Website-with-PHP-MySQL-jQuery,代码行数:30,代码来源:edit.php

示例10: array

     $objValid->_special = array(array('field' => 'personal_email', 'case_type' => 'check_is_email'));
 }
 if (!empty($member['phone']) && empty($phone)) {
     $objValid->_required[] = 'phone';
 }
 if (!empty($member['facebook']) && empty($facebook)) {
     $objValid->_required[] = 'facebook';
 }
 if (!empty($member['high_school']) && empty($high_school)) {
     $objValid->_required[] = 'high_school';
 }
 if (!empty($member['uni']) && empty($uni)) {
     $objValid->_required[] = 'uni';
 }
 if (empty($high_school) && !empty($grad_year_h)) {
     $objValid->add2Errors('high_school');
 }
 if (!empty($high_school) && empty($grad_year_h)) {
     $objValid->add2Errors('grad_year_h');
 }
 $email = $objForm->getPost('personal_email');
 $facebook = $objForm->getPost('facebook');
 if ($objMember->isDuplicateEmail($email, $id)) {
     $objValid->add2Errors('duplicate_email');
 }
 $params = $objValid->objForm->getPostArray($objValid->_expected);
 if (!empty($high_school)) {
     $get_high_school = $objSchool->getSchoolByName(trim($high_school), true);
     if (!empty($get_high_school)) {
         $high_school_id = $get_high_school['id'];
         $params['high_school'] = $high_school_id;
开发者ID:nguyengiangoc,项目名称:SugarKMS,代码行数:31,代码来源:edit.php


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