本文整理汇总了PHP中validation::check方法的典型用法代码示例。如果您正苦于以下问题:PHP validation::check方法的具体用法?PHP validation::check怎么用?PHP validation::check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类validation
的用法示例。
在下文中一共展示了validation::check方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_check
/**
* Tests Validation::check()
*
* @test
* @covers Validation::check
* @covers Validation::rule
* @covers Validation::rules
* @covers Validation::errors
* @covers Validation::error
* @dataProvider provider_check
* @param array $array The array of data
* @param array $rules The array of rules
* @param array $labels The array of labels
* @param boolean $expected Is it valid?
* @param boolean $expected_errors Array of expected errors
*/
public function test_check($array, $rules, $labels, $expected, $expected_errors)
{
$validation = new Validation($array);
foreach ($labels as $field => $label) {
$validation->label($field, $label);
}
foreach ($rules as $field => $field_rules) {
foreach ($field_rules as $rule) {
$validation->rule($field, $rule[0], $rule[1]);
}
}
$status = $validation->check();
$errors = $validation->errors(TRUE);
$this->assertSame($expected, $status);
$this->assertSame($expected_errors, $errors);
$validation = new validation($array);
foreach ($rules as $field => $rules) {
$validation->rules($field, $rules);
}
$validation->labels($labels);
$this->assertSame($expected, $validation->check());
}
示例2: user
<?php
require_once '/opt/lampp/htdocs/MySpace/src/init.php';
$user = new user();
if (!$user->isLoggedIn()) {
redirect::to('index.php');
}
if (input::exists()) {
if (token::check(input::get('token'))) {
$validate = new validation();
$validation = $validate->check($_POST, array('Password' => array('required' => true, 'min' => 8), 'Npassword' => array('required' => true, 'min' => 8), 'Rpassword' => array('required' => true, 'min' => 8, 'matches' => 'Npassword')));
if ($validation->passed()) {
if (hash::make(input::get('Password')) !== $user->data()->Password) {
echo 'your old password did not match';
} else {
if ($user->update(array('Password' => hash::make(input::get('Npassword'))))) {
session::flash('home', 'Your password have been updated!!');
redirect::to('index.php');
}
}
}
}
}
?>
<link href="<?php
echo 'register.css';
?>
" rel='stylesheet' type='text/css'>
<form action="" method="post">
<div class="field">
<label id="icon" for="Password"><i class="icon-shield"></i></label>
示例3: user
<?php
require_once '/opt/lampp/htdocs/MySpace/src/init.php';
if (session::exists('home')) {
echo '<p>' . session::flash('home') . '</p>';
}
$user = new user();
if ($user->isLoggedIn()) {
redirect::to('index.php');
} else {
if (input::exists()) {
if (token::check(input::get('token'))) {
$validate = new validation();
$validation = $validate->check($_POST, array('UserID' => array('required' => true), 'Password' => array('required' => true)));
if ($validation->passed()) {
$user = new user();
$remember = input::get('remember') === 'on' ? true : false;
//echo hash::make ( input::get ( 'Password' ) );
$login = $user->login(input::get('UserID'), input::get('Password'));
if ($login) {
redirect::to('index.php');
} else {
echo '<p>' . 'Invalid credentials, please try again' . '</p>';
}
} else {
foreach ($validation->errors() as $error) {
echo $error . '<br>';
}
}
}
}
示例4: user
<?php
require_once '/opt/lampp/htdocs/MySpace/src/init.php';
$user = new user();
//echo $user->data()->node_id;
if (!$user->isLoggedIn()) {
redirect::to('index.php');
}
if (input::exists()) {
if (token::check(input::get('token'))) {
//echo $user->data()->node_id;
$validate = new validation();
$validation = $validate->check($_POST, array('FirstName' => array('required' => true, 'min' => 2, 'max' => 20), 'LastName' => array('required' => true, 'min' => 2, 'max' => 20), 'CurrentTown' => array('required' => true, 'min' => 2, 'max' => 20), 'Hometown' => array('required' => true, 'min' => 2, 'max' => 20)));
if ($validation->passed()) {
try {
$user->update(array('FirstName' => input::get('FirstName'), 'LastName' => input::get('LastName'), 'CurrentTown' => input::get('CurrentTown'), 'Hometown' => input::get('Hometown')));
session::flash('home', 'Your details have been updated!!');
redirect::to('index.php');
} catch (Exception $e) {
die($e->getMessage());
}
} else {
foreach ($validation->errors() as $error) {
echo $error, '<br>';
}
}
}
}
?>
<!DOCTYPE Funspecified PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<link href="<?php
示例5: validation
<?php
require_once '/opt/lampp/htdocs/MySpace/src/init.php';
//below is for get input from user.
/*
if(input::exists()){
echo input::get('FName');
}*/
//var_dump(token::check(input::get('token')));
if (input::exists()) {
if (token::check(input::get('token'))) {
// echo 'token is working!!';
$validate = new validation();
$validation = $validate->check($_POST, array('emailAddr' => array('required' => true, 'min' => 2, 'max' => 20), 'FirstName' => array('required' => true, 'min' => 2, 'max' => 20), 'LastName' => array('required' => true, 'min' => 2, 'max' => 20), 'DOB' => array('required' => true), 'UserID' => array('required' => true, 'min' => 2, 'max' => 20, 'unique' => 'UserID'), 'Password' => array('required' => true, 'min' => 8, 'max' => 20), 'Gender' => array('required' => true)));
if ($validation->passed()) {
$user = new user();
//$gender = form_input($_POST["gender"]);
//$salt=hash::salt(32);
try {
$user->create(array('EmailAddress' => input::get('emailAddr'), 'FirstName' => input::get('FirstName'), 'LastName' => input::get('LastName'), 'DOB' => input::get('DOB'), 'UserID' => input::get('UserID'), 'Password' => hash::make(trim(input::get('Password'))), 'Gender' => input::get('Gender'), 'Group' => 1));
//header('Location: index.php');
//redirect::to('login.php');
//echo $user->data()->Gender;
} catch (Exception $e) {
echo $e->getMessage();
}
session::flash('home', 'You have been registered and can login');
redirect::to('login.php');
//echo 'passed!';
//session::flash('Sucess!!', 'Your are registered!');
} else {