Пример #1
0
 function subscribe()
 {
     $output = array();
     if (isset($_POST['data_ne']) && $_POST) {
         parse_str($_POST['data_ne'], $params);
         //Your+email
         //terms=on
         //ne=O+seu+email&terms=on
         $email = $params['ne'];
         $terms = $params['terms'];
         $validation = new ValidFluent($params);
         $invalid_email = ICL_LANGUAGE_CODE == 'en' ? 'Please enter a valid email address.' : 'Por favor, insira um email válido.';
         $requerid = ICL_LANGUAGE_CODE == 'en' ? 'Please enter a valid email address.' : 'Por favor, insira um email válido.';
         $invalid_terms = ICL_LANGUAGE_CODE == 'en' ? 'You must accept the terms and conditions.' : 'Deve aceitar os termos e condições.';
         $validation->name('ne')->required($requerid)->email($invalid_email);
         if (preg_match("#(Your email|O seu email )#", $email)) {
             $errors = array('error' => $invalid_email);
             $output = array('error' => 1, 'message' => json_encode($errors));
         } elseif (!$validation->isGroupValid()) {
             $errors = array('error' => $validation->getError('ne'));
             $output = array('error' => 1, 'message' => json_encode($errors));
         } elseif (empty($terms)) {
             $errors = array('error' => $invalid_terms);
             $output = array('error' => 1, 'message' => json_encode($errors));
         } else {
             $output = array('error' => 0, 'message' => $this->subscription_knews($params));
         }
     }
     echo json_encode($output);
     die;
 }
Пример #2
0
<?php

include 'validFluent.php';
if (empty($_POST)) {
    // setting some start values
    $vf = new ValidFluent(array());
    $vf->name('userName')->setValue('legolas')->setError('ooopps, name already in use!');
} else {
    //validate $_POST data
    $vf = new ValidFluent($_POST);
    $vf->name('email')->required('you need to type someting here')->email()->minSize(8);
    $vf->name('date')->required()->date();
    //can also be used like this....
    if ($vf->name('userName')->alfa()->minSize(3)->maxSize(12)->name('choseOne')->oneOf('en:es:fr:pt:other')->name('password1')->required()->minSize(3)->alfa()->name('password2')->required()->equal($_POST['password1'], 'passwords didnt match')->isGroupValid()) {
        echo "Validation Passed \n";
    } else {
        echo "validation errors";
    }
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<style type="text/css">
	    .error
	    {
		color:red;
	    }
	</style>
        <title></title>