PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.smarty.general > RE: [SMARTY] SmartyValidate 2.6 and Smarty 2.6.12 doesn't work ...
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
RE: [SMARTY] SmartyValidate 2.6 and Smarty 2.6.12 doesn't work ...

Réponse
 
LinkBack Outils de la discussion
Vieux 23/01/2006, 17h57   #1
Monte Ohrt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] SmartyValidate 2.6 and Smarty 2.6.12 doesn't work ...

The form is not validating at all? Try this:

if (empty($_POST))

remove the registration check.

When you first come to the form, it should register it. When you submit
the form, it should validate it.

Reynier Perez Mira wrote:

>Nothing ... Monte excuse me if I a little stupid. I change the code again but the form still send without any validate. I check the session file and this is the content:
>-----------------------------------------------
>SmartyValidate|a:1:{s:7:"default";a:4:{s:16:"regi stered_funcs";a:2:{s:8:"criteria";a:0:{}s:9:"trans form";a:0:{}}s:10:"validators";a:2:{i:0;a:8:{s:5:" field";s:6:"uLogin";s:2:"id";s:4:"uLog";s:8:"crite ria";s:8:"notEmpty";s:7:"message";s:37:"El campo usuario no puede estar vacío";s:4:"trim";b:0;s:5:"empty";b:0;s:4:"halt";b :0;s:9:"transform";N;}i:1;a:8:{s:5:"field";s:7:"uP asswd";s:2:"id";s:4:"uPas";s:8:"criteria";s:8:"not Empty";s:7:"message";s:40:"El campo contraseña no puede estar vacío";s:4:"trim";b:0;s:5:"empty";b:0;s:4:"halt";b :0;s:9:"transform";N;}}s:8:"is_error";b:0;s:7:"is_ init";b:0;}}
>-----------------------------------------------
>So if Smarty working fine I believe, what's really wrong here? I can find it.
>
>Regards
>ReynierPM
>4to. año Ing. Informática
>Usuario registrado de Linux: #310201
>************************************************* ************************
>El programador superhéroe aprende de compartir sus conocimientos.
>Es el referente de sus compañeros. Todo el mundo va a preguntarle
>y él, secretamente, lo fomenta porque es así como adquiere su legendaria
>sabiduría: escuchando ayudando a los demás...
>
>-----Mensaje original-----
>De: Monte Ohrt [mailto:monte@ohrt.com]
>Enviado el: Monday, January 23, 2006 11:45 am
>Para: Reynier Perez Mira
>CC: smarty-general@lists.php.net
>Asunto: Re: [SMARTY] SmartyValidate 2.6 and Smarty 2.6.12 doesn't work ...
>
>The form needs reset each time it is "new", so maybe use empty($_POST)
>along with the register test:
>
>if(!SmartyValidate::is_registered_form() || empty($_POST)) {
>
>
>
>Reynier Perez Mira wrote:
>
>
>
>>Well, I follow your instructions and change the bad code. The code now is this:
>>--------------------------------
>>if(!SmartyValidate::is_registered_form('default' )) {
>> SmartyValidate::connect($tpl, true);
>> SmartyValidate::register_validator('uLog','uLogin' ,'notEmpty');
>> SmartyValidate::register_validator('uPas','uPasswd ','notEmpty');
>> $tpl->display('a_home.tpl');
>> } else {
>> SmartyValidate::connect($tpl);
>> if(SmartyValidate::is_valid($_POST)) {
>> SmartyValidate::disconnect();
>> $tpl->display('success.tpl');
>> } else {
>> $tpl->assign($_POST);
>> $tpl->display('a_home.tpl');
>> }
>> }
>>--------------------------------
>>But when I submit the form and leave fields empty, nothing is validate!!! So ... when I click the back button in my FF browser then the messages: " El campo usuario no puede estar vacío" and " El campo contraseña no puede estar vacío" appears. Why this?
>>
>>
>>Regards
>>ReynierPM
>>4to. año Ing. Informática
>>Usuario registrado de Linux: #310201
>>************************************************ *************************
>>El programador superhéroe aprende de compartir sus conocimientos.
>>Es el referente de sus compañeros. Todo el mundo va a preguntarle
>>y él, secretamente, lo fomenta porque es así como adquiere su legendaria
>>sabiduría: escuchando ayudando a los demás...
>>
>>-----Mensaje original-----
>>De: Monte Ohrt [mailto:monte@ohrt.com]
>>Enviado el: Monday, January 23, 2006 11:34 am
>>Para: Reynier Perez Mira
>>CC: smarty-general@lists.php.net
>>Asunto: Re: [SMARTY] SmartyValidate 2.6 and Smarty 2.6.12 doesn't work ...
>>
>>that is the name of the form. if you didn't name it when you registered,
>>then 'default' is correct. You can also leave it empty:
>>
>>is_registered_form()
>>
>>Reynier Perez Mira wrote:
>>
>>
>>
>>
>>
>>>Hi Monte:
>>>Understand every, but I have one doubt: what's 'default'? a name for a form or a id or something ...
>>>
>>>Best,
>>>ReynierPM
>>>4to. año Ing. Informática
>>>Usuario registrado de Linux: #310201
>>>*********************************************** **************************
>>>El programador superhéroe aprende de compartir sus conocimientos.
>>>Es el referente de sus compañeros. Todo el mundo va a preguntarle
>>>y él, secretamente, lo fomenta porque es así como adquiere su legendaria
>>>sabiduría: escuchando ayudando a los demás...
>>>
>>>-----Mensaje original-----
>>>De: Monte Ohrt [mailto:monte@ohrt.com]
>>>Enviado el: Monday, January 23, 2006 10:51 am
>>>Para: Reynier Perez Mira
>>>CC: smarty-general@lists.php.net
>>>Asunto: Re: [SMARTY] SmartyValidate 2.6 and Smarty 2.6.12 doesn't work ...
>>>
>>>Monte Ohrt wrote:
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>>Your code is almost right, just change:
>>>>
>>>>if(SmartyValidate::is_valid($_POST)) {
>>>>
>>>>to:
>>>>
>>>>if(!empty($_POST)) {
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>oops, make that:
>>>
>>>if(empty($_POST)) {
>>>
>>>I'll note that testing if $_POST is empty isn't always an accurate
>>>approach in every situation, another approach is to test if the form is
>>>registered:
>>>
>>>if (!SmartyValidate::is_registered_form('default')) {
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>>Reynier Perez Mira wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>Hi:
>>>>>Well, after all and a little latest (¿Jan 23?) "Happy New Year".
>>>>>I try to construct a web application in these days. I decide use
>>>>>Smarty as my template engine because it's perfectly and powerful. I
>>>>>have some form in which user can add news, sign guestbook and some
>>>>>other stuff. These form need to be validate after send it to
>>>>>database. So ... searching in Smarty forum I found SmartyValidate class.
>>>>>I read the doc form website and setup this in my application:
>>>>>
>>>>>index.php
>>>>>------------------------------------------------------------------
>>>>>/* Start new session each time */
>>>>>session_start();
>>>>>
>>>>>setlocale(LC_ALL, 'esp_ESP');
>>>>>
>>>>>include_once('../config.inc.php');
>>>>>require_once('../api/smarty/Smarty.class.php');
>>>>>require_once('../api/smarty/SmartyValidate.class.php');
>>>>>include_once('../api/dbase/adodb-exceptions.inc.php');
>>>>>include_once('../api/dbase/adodb.inc.php');
>>>>>
>>>>>/* Setup Smarty Class */
>>>>>$tpl = new Smarty();
>>>>>$tpl->template_dir = '../' . cnf_TemplateDir;
>>>>>$tpl->compile_dir = '../' . cnf_TemplateDir . cnf_CompileDir;
>>>>>$tpl->config_dir = '../' . cnf_TemplateDir . cnf_ConfigDir;
>>>>>$tpl->cache_dir = '../' . cnf_TemplateDir . cnf_CacheDir;
>>>>>$tpl->compile_check = cnf_CompileCheck;
>>>>>$tpl->debugging = false;
>>>>>
>>>>>if(SmartyValidate::is_valid($_POST)) {
>>>>>SmartyValidate::connect($tpl, true);
>>>>>SmartyValidate::register_validator('uLog','uL ogin','notEmpty');
>>>>>SmartyValidate::register_validator('uPas','uP asswd','notEmpty');
>>>>>$tpl->display('a_home.tpl');
>>>>>} else {
>>>>>SmartyValidate::connect($tpl);
>>>>> if(SmartyValidate::is_valid($_POST)) {
>>>>> SmartyValidate::disconnect();
>>>>> $tpl->display('success.tpl');
>>>>> } else {
>>>>> $tpl->assign($_POST);
>>>>> $tpl->display('a_home.tpl');
>>>>> }
>>>>>}
>>>>>------------------------------------------------------------------
>>>>>
>>>>>a_home.tpl
>>>>>------------------------------------------------------------------
>>>>><form name="frm_aLogin" id="frm_aLogin" method="post"
>>>>>action="index.php?opt=chkuLogin" enctype="multipart/form-data">
>>>>><fieldset>
>>>>><legend>Login de Administrador</legend> <table width="100%"
>>>>>cellpadding="0" cellspacing="0" border="0">
>>>>> <tr>
>>>>> <td width="25%" class="derecha">Usuario:</td>
>>>>> <td width="75%">
>>>>> <input type="text" name="uLogin" id="uLogin" size="35"
>>>>>maxlength="35" />{validate id="uLog" message="El campo usuario no
>>>>>puede estar vacío"}
>>>>> </td>
>>>>> </tr>
>>>>> <tr>
>>>>> <td class="derecha">Contraseña:</td>
>>>>> <td><input type="password" name="uPasswd" id="uPasswd" size="35"
>>>>>maxlength="250" />{validate id="uPas" message="El campo contraseña no
>>>>>puede estar vacío"}
>>>>> </td>
>>>>> </tr>
>>>>> <tr>
>>>>> <td class="centro" colspan="2"><input type="submit"
>>>>>name="btn_Login" id="btn_Login" value="Entrar ..." /></td>
>>>>> </tr>
>>>>> </table>
>>>>> </fieldset>
>>>>></form>
>>>>>------------------------------------------------------------------
>>>>>
>>>>>As you can see, nothing is strange here in this code. Well when I
>>>>>call the file from my FF browser, ex: http://localhost/admincp/index.php
>>>>>This warnings appear:
>>>>>------------------------------------------------------------------
>>>>>Warning: Smarty error: validate: validator id 'uLog' is not
>>>>>registered. in D:\WebServer\WWW\simpro\api\smarty\Smarty.class.ph p on
>>>>>line 1095
>>>>>
>>>>>Warning: Smarty error: validate: validator id 'uPas' is not
>>>>>registered. in D:\WebServer\WWW\simpro\api\smarty\Smarty.class.ph p on
>>>>>line 1095
>>>>>------------------------------------------------------------------
>>>>>
>>>>>What's wrong in my code?
>>>>>I work with PHP 5.1.2, have this something to see?
>>>>>
>>>>>Best, ReynierPM
>>>>>4to. año Ing. Informática
>>>>>Usuario registrado de Linux: #310201
>>>>>********************************************* ****************************
>>>>>
>>>>>El programador superhéroe aprende de compartir sus conocimientos. Es
>>>>>el referente de sus compañeros. Todo el mundo va a preguntarle y él,
>>>>>secretamente, lo fomenta porque es así como adquiere su legendaria
>>>>>sabiduría: escuchando ayudando a los demás...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>
>>>
>>>
>>>

>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>

>
>
>
>
>
>
>
>
>!DSPAM:43d51809286061294912330!
>
>
>
>

  Réponse avec citation
Vieux 23/01/2006, 18h51   #2
Reynier Perez Mira
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: [SMARTY] SmartyValidate 2.6 and Smarty 2.6.12 doesn't work ...

Nothing ... Monte excuse me if I a little stupid. I change the code again but the form still send without any validate. I check the session file and this is the content:
-----------------------------------------------
SmartyValidate|a:1:{s:7:"default";a:4:{s:16:"regis tered_funcs";a:2:{s:8:"criteria";a:0:{}s:9:"transf orm";a:0:{}}s:10:"validators";a:2:{i:0;a:8:{s:5:"f ield";s:6:"uLogin";s:2:"id";s:4:"uLog";s:8:"criter ia";s:8:"notEmpty";s:7:"message";s:37:"El campo usuario no puede estar vacío";s:4:"trim";b:0;s:5:"empty";b:0;s:4:"halt";b :0;s:9:"transform";N;}i:1;a:8:{s:5:"field";s:7:"uP asswd";s:2:"id";s:4:"uPas";s:8:"criteria";s:8:"not Empty";s:7:"message";s:40:"El campo contraseña no puede estar vacío";s:4:"trim";b:0;s:5:"empty";b:0;s:4:"halt";b :0;s:9:"transform";N;}}s:8:"is_error";b:0;s:7:"is_ init";b:0;}}
-----------------------------------------------
So if Smarty working fine I believe, what's really wrong here? I can find it.

Regards
ReynierPM
4to. año Ing. Informática
Usuario registrado de Linux: #310201
************************************************** ***********************
El programador superhéroe aprende de compartir sus conocimientos.
Es el referente de sus compañeros. Todo el mundo va a preguntarle
y él, secretamente, lo fomenta porque es así como adquiere su legendaria
sabiduría: escuchando ayudando a los demás...

-----Mensaje original-----
De: Monte Ohrt [mailto:monte@ohrt.com]
Enviado el: Monday, January 23, 2006 11:45 am
Para: Reynier Perez Mira
CC: smarty-general@lists.php.net
Asunto: Re: [SMARTY] SmartyValidate 2.6 and Smarty 2.6.12 doesn't work ....

The form needs reset each time it is "new", so maybe use empty($_POST)
along with the register test:

if(!SmartyValidate::is_registered_form() || empty($_POST)) {



Reynier Perez Mira wrote:

>Well, I follow your instructions and change the bad code. The code now is this:
>--------------------------------
>if(!SmartyValidate::is_registered_form('default') ) {
> SmartyValidate::connect($tpl, true);
> SmartyValidate::register_validator('uLog','uLogin' ,'notEmpty');
> SmartyValidate::register_validator('uPas','uPasswd ','notEmpty');
> $tpl->display('a_home.tpl');
> } else {
> SmartyValidate::connect($tpl);
> if(SmartyValidate::is_valid($_POST)) {
> SmartyValidate::disconnect();
> $tpl->display('success.tpl');
> } else {
> $tpl->assign($_POST);
> $tpl->display('a_home.tpl');
> }
> }
>--------------------------------
>But when I submit the form and leave fields empty, nothing is validate!!! So ... when I click the back button in my FF browser then the messages: " El campo usuario no puede estar vacío" and " El campo contraseña no puede estar vacío" appears. Why this?
>
>
>Regards
>ReynierPM
>4to. año Ing. Informática
>Usuario registrado de Linux: #310201
>************************************************* ************************
>El programador superhéroe aprende de compartir sus conocimientos.
>Es el referente de sus compañeros. Todo el mundo va a preguntarle
>y él, secretamente, lo fomenta porque es así como adquiere su legendaria
>sabiduría: escuchando ayudando a los demás...
>
>-----Mensaje original-----
>De: Monte Ohrt [mailto:monte@ohrt.com]
>Enviado el: Monday, January 23, 2006 11:34 am
>Para: Reynier Perez Mira
>CC: smarty-general@lists.php.net
>Asunto: Re: [SMARTY] SmartyValidate 2.6 and Smarty 2.6.12 doesn't work ....
>
>that is the name of the form. if you didn't name it when you registered,
>then 'default' is correct. You can also leave it empty:
>
>is_registered_form()
>
>Reynier Perez Mira wrote:
>
>
>
>>Hi Monte:
>>Understand every, but I have one doubt: what's 'default'? a name for a form or a id or something ...
>>
>>Best,
>>ReynierPM
>>4to. año Ing. Informática
>>Usuario registrado de Linux: #310201
>>************************************************ *************************
>>El programador superhéroe aprende de compartir sus conocimientos.
>>Es el referente de sus compañeros. Todo el mundo va a preguntarle
>>y él, secretamente, lo fomenta porque es así como adquiere su legendaria
>>sabiduría: escuchando ayudando a los demás...
>>
>>-----Mensaje original-----
>>De: Monte Ohrt [mailto:monte@ohrt.com]
>>Enviado el: Monday, January 23, 2006 10:51 am
>>Para: Reynier Perez Mira
>>CC: smarty-general@lists.php.net
>>Asunto: Re: [SMARTY] SmartyValidate 2.6 and Smarty 2.6.12 doesn't work ....
>>
>>Monte Ohrt wrote:
>>
>>
>>
>>
>>
>>>Your code is almost right, just change:
>>>
>>>if(SmartyValidate::is_valid($_POST)) {
>>>
>>>to:
>>>
>>>if(!empty($_POST)) {
>>>
>>>
>>>
>>>
>>>
>>>

>>oops, make that:
>>
>>if(empty($_POST)) {
>>
>>I'll note that testing if $_POST is empty isn't always an accurate
>>approach in every situation, another approach is to test if the form is
>>registered:
>>
>>if (!SmartyValidate::is_registered_form('default')) {
>>
>>
>>
>>
>>
>>>Reynier Perez Mira wrote:
>>>
>>>
>>>
>>>
>>>
>>>>Hi:
>>>>Well, after all and a little latest (¿Jan 23?) "Happy New Year".
>>>>I try to construct a web application in these days. I decide use
>>>>Smarty as my template engine because it's perfectly and powerful. I
>>>>have some form in which user can add news, sign guestbook and some
>>>>other stuff. These form need to be validate after send it to
>>>>database. So ... searching in Smarty forum I found SmartyValidate class.
>>>>I read the doc form website and setup this in my application:
>>>>
>>>>index.php
>>>>------------------------------------------------------------------
>>>>/* Start new session each time */
>>>>session_start();
>>>>
>>>>setlocale(LC_ALL, 'esp_ESP');
>>>>
>>>>include_once('../config.inc.php');
>>>>require_once('../api/smarty/Smarty.class.php');
>>>>require_once('../api/smarty/SmartyValidate.class.php');
>>>>include_once('../api/dbase/adodb-exceptions.inc.php');
>>>>include_once('../api/dbase/adodb.inc.php');
>>>>
>>>>/* Setup Smarty Class */
>>>>$tpl = new Smarty();
>>>>$tpl->template_dir = '../' . cnf_TemplateDir;
>>>>$tpl->compile_dir = '../' . cnf_TemplateDir . cnf_CompileDir;
>>>>$tpl->config_dir = '../' . cnf_TemplateDir . cnf_ConfigDir;
>>>>$tpl->cache_dir = '../' . cnf_TemplateDir . cnf_CacheDir;
>>>>$tpl->compile_check = cnf_CompileCheck;
>>>>$tpl->debugging = false;
>>>>
>>>>if(SmartyValidate::is_valid($_POST)) {
>>>>SmartyValidate::connect($tpl, true);
>>>>SmartyValidate::register_validator('uLog','uLo gin','notEmpty');
>>>>SmartyValidate::register_validator('uPas','uPa sswd','notEmpty');
>>>>$tpl->display('a_home.tpl');
>>>>} else {
>>>>SmartyValidate::connect($tpl);
>>>> if(SmartyValidate::is_valid($_POST)) {
>>>> SmartyValidate::disconnect();
>>>> $tpl->display('success.tpl');
>>>> } else {
>>>> $tpl->assign($_POST);
>>>> $tpl->display('a_home.tpl');
>>>> }
>>>>}
>>>>------------------------------------------------------------------
>>>>
>>>>a_home.tpl
>>>>------------------------------------------------------------------
>>>><form name="frm_aLogin" id="frm_aLogin" method="post"
>>>>action="index.php?opt=chkuLogin" enctype="multipart/form-data">
>>>><fieldset>
>>>> <legend>Login de Administrador</legend> <table width="100%"
>>>>cellpadding="0" cellspacing="0" border="0">
>>>> <tr>
>>>> <td width="25%" class="derecha">Usuario:</td>
>>>> <td width="75%">
>>>> <input type="text" name="uLogin" id="uLogin" size="35"
>>>>maxlength="35" />{validate id="uLog" message="El campo usuario no
>>>>puede estar vacío"}
>>>> </td>
>>>> </tr>
>>>> <tr>
>>>> <td class="derecha">Contraseña:</td>
>>>> <td><input type="password" name="uPasswd" id="uPasswd" size="35"
>>>>maxlength="250" />{validate id="uPas" message="El campo contraseña no
>>>>puede estar vacío"}
>>>> </td>
>>>> </tr>
>>>> <tr>
>>>> <td class="centro" colspan="2"><input type="submit"
>>>>name="btn_Login" id="btn_Login" value="Entrar ..." /></td>
>>>> </tr>
>>>> </table>
>>>> </fieldset>
>>>> </form>
>>>>------------------------------------------------------------------
>>>>
>>>>As you can see, nothing is strange here in this code. Well when I
>>>>call the file from my FF browser, ex: http://localhost/admincp/index.php
>>>>This warnings appear:
>>>>------------------------------------------------------------------
>>>>Warning: Smarty error: validate: validator id 'uLog' is not
>>>>registered. in D:\WebServer\WWW\simpro\api\smarty\Smarty.class.ph p on
>>>>line 1095
>>>>
>>>>Warning: Smarty error: validate: validator id 'uPas' is not
>>>>registered. in D:\WebServer\WWW\simpro\api\smarty\Smarty.class.ph p on
>>>>line 1095
>>>>------------------------------------------------------------------
>>>>
>>>>What's wrong in my code?
>>>>I work with PHP 5.1.2, have this something to see?
>>>>
>>>>Best, ReynierPM
>>>>4to. año Ing. Informática
>>>>Usuario registrado de Linux: #310201
>>>>********************************************** ***************************
>>>>
>>>>El programador superhéroe aprende de compartir sus conocimientos. Es
>>>>el referente de sus compañeros. Todo el mundo va a preguntarle y él,
>>>>secretamente, lo fomenta porque es así como adquiere su legendaria
>>>>sabiduría: escuchando ayudando a los demás...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>

>>
>>
>>
>>

>
>
>
>
>
>
>
>
>!DSPAM:43d5151d125027126579485!
>
>
>
>

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 23h22.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,20677 seconds with 10 queries