Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- // load Smarty library
- require('Smarty.class.php');
- require('SmartyValidate.class.php');
- $smarty = new Smarty;
- $smarty->template_dir = 'c:/inetpub/wwwroot/smarty/templates';
- $smarty->config_dir = ' c:/inetpub/wwwroot/smarty/config';
- $smarty->cache_dir = 'c:/smarty/smarty_cache';
- $smarty->compile_dir = 'c:/smarty/smarty_templates_c';
- if(empty($_POST)) {
- // new form, we (re)set the session data
- SmartyValidate::connect($smarty, true);
- // register our validators
- SmartyValidate::register_validator('fullname', 'FullName', 'notEmpty',
- false, false, 'trim');
- SmartyValidate::register_validator('phone', 'Phone', 'isNumber', true,
- false, 'trim');
- SmartyValidate::register_validator('expdate', 'CCExpDate', 'notEmpty',
- false, false, 'trim');
- SmartyValidate::register_validator('email', 'Email', 'isEmail', false,
- false, 'trim');
- SmartyValidate::register_validator('date', 'Date', 'isDate', true,
- false, 'trim');
- SmartyValidate::register_validator('password', 'password:password2', 'isEqual');
- // display form
- $smarty->display('form.tpl');
- } else {
- // validate after a POST
- SmartyValidate::connect($smarty);
- if(SmartyValidate::is_valid($_POST)) {
- // no errors, done with SmartyValidate
- SmartyValidate::disconnect();
- $smarty->display('success.tpl');
- } else {
- // error, redraw the form
- $smarty->assign($_POST);
- $smarty->display('form.tpl');
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement