我需要使用GUMP验证类来验证我的表单数据,但是如何单独获取每个字段错误
如何显示每个字段错误
<?php
if (isset($_POST['submit'])){
require "gump.class.php";
$validator = new GUMP();
$us = $_POST['username'];
$pwd = $_POST['password'];
// Set the data
$_POST = array('username' => $us,'password' => $pwd);
$_POST = $validator->sanitize($_POST);
$rules = array('username' => 'required','password' => 'required|max_len,100|min_len,6');
$filters = array('username' => 'trim|sanitize_string','password' => 'trim|base64_encode');
$_POST = $validator->filter($_POST, $filters);
$validated = $validator->validate($_POST, $rules);
if ($validated === TRUE){
echo "Successful Validation\n\n";
print_r($_POST);
exit;
} else {
echo $validator->get_readable_errors(true);
}
}
?>