daily pastebin goal
69%
SHARE
TWEET

Untitled

tflagg Nov 8th, 2012 14 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. session_start();
  3.  
  4. // load Smarty library
  5. require('Smarty.class.php');
  6. require('SmartyValidate.class.php');
  7.  
  8. $smarty = new Smarty;
  9.  
  10. $smarty->template_dir = 'c:/inetpub/wwwroot/smarty/templates';
  11. $smarty->config_dir = ' c:/inetpub/wwwroot/smarty/config';
  12. $smarty->cache_dir = 'c:/smarty/smarty_cache';
  13. $smarty->compile_dir = 'c:/smarty/smarty_templates_c';
  14.  
  15. if(empty($_POST)) {
  16.         // new form, we (re)set the session data
  17.                
  18.         SmartyValidate::connect($smarty, true);
  19.         // register our validators
  20.         SmartyValidate::register_validator('fullname', 'FullName', 'notEmpty',
  21.             false, false, 'trim');
  22.         SmartyValidate::register_validator('phone', 'Phone', 'isNumber', true,
  23.             false, 'trim');
  24.         SmartyValidate::register_validator('expdate', 'CCExpDate', 'notEmpty',
  25.             false, false, 'trim');
  26.         SmartyValidate::register_validator('email', 'Email', 'isEmail', false,
  27.             false, 'trim');
  28.         SmartyValidate::register_validator('date', 'Date', 'isDate', true,
  29.             false, 'trim');
  30.         SmartyValidate::register_validator('password', 'password:password2', 'isEqual');
  31.         // display form
  32.         $smarty->display('form.tpl');
  33.     } else {    
  34.        // validate after a POST
  35.        SmartyValidate::connect($smarty);
  36.        if(SmartyValidate::is_valid($_POST)) {
  37.            // no errors, done with SmartyValidate
  38.            SmartyValidate::disconnect();
  39.            $smarty->display('success.tpl');
  40.        } else {
  41.            // error, redraw the form
  42.            $smarty->assign($_POST);
  43.            $smarty->display('form.tpl');
  44.        }
  45.     }
  46.        
  47. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top