Tweakers!
Ik ben bezig om een site te maken met behulp van Smarty, hier is ook een hele handige plugin voor te vinden, nl. SmartyValidate (http://www.phpinsider.com/php/code/SmartyValidate/)
Het probleem is alleen, dat ik deze plugin niet goed werkend kan krijgen..
Ik krijg namelijk de volgende foutmeldingen:
Dit zijn de codes:
registratie.php
registratie.tpl
index.php
Ik ben bezig om een site te maken met behulp van Smarty, hier is ook een hele handige plugin voor te vinden, nl. SmartyValidate (http://www.phpinsider.com/php/code/SmartyValidate/)
Het probleem is alleen, dat ik deze plugin niet goed werkend kan krijgen..
Ik krijg namelijk de volgende foutmeldingen:
code:
Etc..1
| Warning: Smarty error: validate: validator id 'fusername' is not registered. in C:\xampp\htdocs\smarty\libs\Smarty.class.php on line 1095 |
Dit zijn de codes:
registratie.php
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| <?php $smarty->assign('content_title','Registreren'); require_once('smarty/libs/SmartyValidate.class.php'); if(empty($_POST)) { SmartyValidate::connect($smarty, true); SmartyValidate::register_validator('fusername','Username','notEmpty'); SmartyValidate::register_validator('fwachtwoord1','Wachtwoord1','notEmpty'); SmartyValidate::register_validator('fwachtwoord2','Wachtwoord2','notEmpty'); SmartyValidate::register_validator('femail','Email','notEmpty'); $smarty->assign('template', 'registratie.tpl'); } else { SmartyValidate::connect($smarty); // validate after a POST if(SmartyValidate::is_valid($_POST)) { // no errors, done with SmartyValidate SmartyValidate::disconnect(); echo 'Gelukt!'; } else { // error, redraw the form $smarty->assign($_POST); $smarty->assign('template', 'registratie.tpl'); } } ?> |
registratie.tpl
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| <form name="registreer" method="post" action="{$domein}/profiel/registreren" enctype="multipart/form-data"> Om te registeren moet je onderstaand formulier even invullen! <fieldset> <legend>Account Gegevens</legend> {validate id="fusername" message="Vul een gebruikersnaam in!"} <label for="username">Username</label> <input type="text" name="Username" id="username" /><br /> {validate id="fwachtwoord1" message="Vul een wachtwoord in!<br>"} <label for="wachtwoord">Wachtwoord</label> <input type="password" name="Wachtwoord1"/><br /> {validate id="fwachtwoord2" message="Vul ook hier een wachtwoord in!<br>"} <label for="wachtwoord2">Wachtwoord <i>(controle)</i> </label> <input type="password" name="Wachtwoord2" id="wachtwoord2"/><br /> {validate id="femail" message="Vul een geldig emailadres in!<br>"} <label for="email">E-mail</label> <input type="text" name="Email" id="email" value="{$email|escape}"/> </fieldset> // Nog meer inputs... <fieldset> <legend>Controleren</legend> <label for="akkoord">Ik ga akkoord met de regels</label><input type="checkbox" name="akkoord" id="akkoord"><br /><br /> <input type="submit" class="submit" value="Versturen!"> </fieldset> <input type="hidden" name="registreer_form" value="1"> </form> |
index.php
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
| <?php require_once('smarty/libs/Smarty.class.php'); $smarty = new Smarty(); $smarty->template_dir = 'smarty/templates/'; $smarty->compile_dir = 'smarty/templates_c/'; $smarty->config_dir = 'smarty/configs/'; $smarty->cache_dir = 'smarty/cache/'; $smarty->assign('domein', 'http://localhost'); $pad = explode('/', $_SERVER['REQUEST_URI']); $smarty->assign('location', $pad[1]); $onderdeel = $pad[1]; $pagina = $pad[2]; if ($onderdeel == '') { // de code voor nieuwspagina's include ('home.php'); } if ($onderdeel == 'profiel') { if ($pagina == 'registreren') { include ('profiel/registratie.php'); } } //** un-comment the following line to show the debug console $smarty->debugging = true; $smarty->display('index.tpl'); ?> |
[ Voor 12% gewijzigd door annuh op 12-03-2008 14:53 ]