本文整理汇总了PHP中Validator::validateName方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::validateName方法的具体用法?PHP Validator::validateName怎么用?PHP Validator::validateName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validator
的用法示例。
在下文中一共展示了Validator::validateName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setName
public function setName($string)
{
$validator = new Validator();
if ($validator->validateName($string)) {
}
$this->name = $string;
}
示例2: userIsValid
public static function userIsValid($user)
{
$validArray = array();
$valid['ue'] = Validator::validateUe($user->ue());
$valid['name'] = Validator::validateName($user->name());
$valid['email'] = Validator::validateEMail($user->email());
$valid['tel'] = Validator::validateTel($user->tel());
$valid['password'] = Validator::validatePassword($user->password());
return !in_array(false, $validArray);
}
示例3: actionLogin
function actionLogin($params = '')
{
if (!empty($params['email']) && !empty($params['password'])) {
if ($this->objAuthentication->login($params['email'], $params['password'])) {
//no errors, continue to home
/*$objDispatcher = new Dispatcher;
$objDispatcher->setController('Forum');
$objDispatcher->setAction('Index');
$objDispatcher->setParams($params);
$objDispatcher->dispatch();*/
$this->actionIndex($params);
} else {
$this->view->assign('errorMsg', 'Unable to login, try again.');
$this->view->assign('content', $this->view->fetch('tpl/community/login.tpl'));
$this->finish();
}
} else {
if (!empty($params['createAccount']) && $params['createAccount'] == 1) {
$errorMessages = array();
$objValidator = new Validator();
$objValidator->reset();
$objValidator->validateEmail($params['create_email']);
$objValidator->validatePassword($params['create_password']);
$objValidator->passwordsMatch($params['create_password'], $params['create_password2']);
$objValidator->validateName($params['create_displayName']);
if ($objValidator->hasError || empty($params['create_terms'])) {
$error = $objValidator->getError();
if (empty($params['create_terms'])) {
$error[] = 'You must agree to the Terms of Use to make an account';
}
$this->view->assign('errorMessages', $error);
$this->view->assign('created', false);
} else {
$userData = array();
$userData['email'] = $params['create_email'];
$userData['password'] = $params['create_password'];
$userData['displayName'] = $params['create_displayName'];
$userModel = new UserModel();
$created = $userModel->createUser($userData);
if (!empty($created)) {
$this->view->assign('created', true);
$objEmail = new Emailer();
$objEmail->setFrom(CONTACT_EMAIL);
$objEmail->setSubject('Retail Roar Community account created');
$objEmail->addTO($userData['email']);
$objEmail->setBody($this->view->fetch('emails/communitysignup.tpl'), true);
$sent = $objEmail->sendMail();
} else {
$this->view->assign('created', false);
$this->view->assign('errorMessages', $userModel->errorMsg);
}
$this->view->assign('submitted', true);
}
$this->view->assign('content', $this->view->fetch('tpl/community/login.tpl'));
$this->finish();
} else {
if ($this->objAuthentication->loggedIn()) {
$this->view->assign('content', 'Already logged in.');
$this->finish();
} else {
$this->view->assign('content', $this->view->fetch('tpl/community/login.tpl'));
$this->finish();
}
}
}
}
示例4: Validator
<?php
/**
* Created by PhpStorm.
* User: Rimas
* Date: 1/27/2016
* Time: 12:03 AM
*/
require 'config.php';
require 'autoload.php';
if (!empty($_POST)) {
$validator = new Validator();
if ($validator->validateName($_POST['name']) && $validator->validateName($_POST['password'])) {
$database = new Database();
if ($database->Connect($servername, $dbname, $username, $password)) {
$database->setTable('users');
$data = $database->GetDataWhere('name', $_POST['name']);
$database->Close();
}
if ($data) {
foreach ($data as $row) {
if ($row['password'] === hash('sha256', $_POST['password'])) {
session_start();
$_SESSION['username'] = $_POST['name'];
header("Location: admin.php");
} else {
echo "Incorrect password";
}
}
} else {
echo "Incorrect name";
示例5: Validator
<?php
/**
* Created by PhpStorm.
* User: Rimas
* Date: 1/27/2016
* Time: 12:03 AM
*/
require 'config.php';
require 'autoload.php';
if (!empty($_POST)) {
$validator = new Validator();
if ($validator->validateName($_POST['name']) == false) {
echo 'Please enter name';
}
if ($validator->validateName($_POST['email']) == false) {
echo 'Please enter email';
}
if ($validator->validatePassword($_POST['password']) == false) {
echo 'Please enter password';
}
if ($validator->validateName($_POST['name']) && $validator->validateName($_POST['email']) && $validator->validatePassword($_POST['password'])) {
$user1 = new User();
$user1->setName($_POST['name']);
$user1->setEmail($_POST['email']);
$user1->setPassword($_POST['password']);
$user1->setMessage($_POST['message']);
$database = new Database();
if ($database->Connect($servername, $dbname, $username, $password)) {
$database->setTable('users');
if (!$database->userExists($_POST['name'])) {
示例6: saveUser
function saveUser($data)
{
// dont trust posted user_id
if (!empty($data['user_id'])) {
if ($data['user_id'] != $this->objAuthentication->user_id) {
// editing someone elses profile
$this->errorMsg = 'Unauthorized';
return false;
}
}
$user_id = false;
$this->errorMsg = null;
$saveData = array();
$saveData['id'] = !empty($data['user_id']) ? intval($data['user_id']) : false;
$saveData['email'] = !empty($data['user_email']) ? $data['user_email'] : false;
$saveData['company'] = !empty($data['user_company']) ? $data['user_company'] : false;
$saveData['title'] = !empty($data['user_title']) ? $data['user_title'] : false;
$saveData['fName'] = !empty($data['user_fName']) ? $data['user_fName'] : false;
$saveData['lName'] = !empty($data['user_lName']) ? $data['user_lName'] : false;
$saveData['phone'] = !empty($data['user_phone']) ? $data['user_phone'] : false;
$saveData['address'] = !empty($data['user_address']) ? $data['user_address'] : false;
$saveData['address2'] = !empty($data['user_address2']) ? $data['user_address2'] : false;
$saveData['city'] = !empty($data['user_city']) ? $data['user_city'] : false;
$saveData['province'] = !empty($data['user_province']) ? $data['user_province'] : false;
$saveData['country'] = !empty($data['user_country']) ? $data['user_country'] : false;
$saveData['zip'] = !empty($data['user_zip']) ? $data['user_zip'] : false;
if (!empty($data['user_password'])) {
$saveData['password'] = !empty($data['user_password']) ? $data['user_password'] : false;
}
if (isset($data['active'])) {
$saveData['active'] = intval($data['active']);
}
if (!empty($data['activateString'])) {
$saveData['activateString'] = $data['activateString'];
}
// validate it all
$objValidator = new Validator();
$objValidator->validateEmail($saveData['email']);
$objValidator->validateName($saveData['fName']);
$objValidator->validateName($saveData['lName']);
$objValidator->validatePhone($saveData['phone']);
$objValidator->validateNotEmpty($saveData['title'], 'title');
$objValidator->validateNotEmpty($saveData['company'], 'company');
$objValidator->validateNotEmpty($saveData['address'], 'address');
$objValidator->validateNotEmpty($saveData['city'], 'city');
$objValidator->validateNotEmpty($saveData['province'], 'province');
$objValidator->validateNotEmpty($saveData['country'], 'country');
$objValidator->validateNotEmpty($saveData['zip'], 'zip');
if (!empty($data['password'])) {
$objValidator->validatePassword($saveData['password']);
@$objValidator->passwordsMatch($saveData['password'], $data['password2']);
}
if ($objValidator->hasError) {
$this->errorMsg = $objValidator->getError();
} else {
$objUser = new UserModel();
$user_id = $objUser->saveUser($saveData);
}
return $user_id;
}