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 30/01/2006, 16h01   #1 (permalink)
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 ...

// Redraw form and send message
print_r('Form not ok');
$tpl->assign('display','register');


You aren't redrawing the form here (?)


Reynier Perez Mira wrote:

>Oww !!!!!, ... This is very to me because I not understand yet how SmartyValidate works. Now I got. The problems in my code still appear.
>1) I recheck my code again. See below changes:
>
>PHP
>---
><?
>include_once('set_app.php');
>// Register form and validators
>if(empty($_POST)){
> SmartyValidate::connect($tpl, true);
> // Register some validators
> SmartyValidate::register_validator('fnombre','uNom bre','notEmpty');
> SmartyValidate::register_validator('fapellidos','u Apellidos','notEmpty');
> // This TPL file contains the form elements and I include in a main file when action register is called from URL. For example: index.php?a=register
> $tpl->assign('display','register');
> } else {
> SmartyValidate::connect($tpl);
> // Check if form was validate or not
> if(SmartyValidate::is_valid($_POST)) {
> // If was then disconect from SmartyValidate
> SmartyValidate::disconnect();
> // Stop execution and send message
> die('Form validate');
> } else {
> // If not redraw the form again
> $tpl->assign($_POST);
> // Redraw form and send message
> print_r('Form not ok');
> $tpl->assign('display','register');
> }
> }
>$tpl->display('main.tpl');
>$tpl->clear_all_assign();
>?>
>
>main.tpl:
>---
>{if $display eq ""}
> {include file="home.tpl"}
>{elseif $display eq "buy_now"}
> {include file="buy_now.tpl"}
>{elseif $display eq "register"}
> {include file="register.tpl"}
>{elseif $display eq "login"}
> {include file="login.tpl"}
>{/if}
>
>This works fine, because when I call index.php?a=register register.tpl file is include, so I discard that this was the error.
>
>register.tpl
>---
><fieldset>
> <legend>Registro de nuevos usuarios</legend>
> <form name="uRegister" id="uRegister" method="post" action="uoptions.php?a=nuevo">
> <table align="center" cellpadding="1" cellspacing="1">
> <tr>
> <td width="89" class="derecha">Nombre:</td>
> <td width="144">
> <input type="text" name="uNombre" id="uNombre" size="35" maxlength="35" value="{$uNombre}">
> {validate id="fnombre" field="uNombre" message="El campo Nombre no puede estar vacio"}
> </td>
> </tr>
> <tr>
> <td class="derecha">Apellidos:</td>
> <td>
> <input type="text" name="uApellidos" id="uApellidos" size="35" maxlength="45" value="{$uApellidos}">
> {validate id="fapellidos" field="uApellidos" message="El campo Apellidos no puede estar vacio"}
> </td>
> </tr>
> <tr><td colspan="2" class="center"><input type="submit" name="btn_Send" value="Enviar"></td></tr>
> </table>
> </form>
></fieldset>
>
>So I can't find the error, because all if in the same way you say me. I just change the example values from your code to match with my code. I check the session var and all are registered: form, validate criteria ... So can't really understand what I'm doing wrong.
>Hint: I cut some code for do more readable and easy.
>
>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...
>
>
>
>
>
>
>
>!DSPAM:43de36fc92591867916590!
>
>
>
>

  Réponse avec citation
Vieux 30/01/2006, 16h56   #2 (permalink)
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 ...

Oww !!!!!, ... This is very to me because I not understand yet how SmartyValidate works. Now I got. The problems in my code still appear.
1) I recheck my code again. See below changes:

PHP
---
<?
include_once('set_app.php');
// Register form and validators
if(empty($_POST)){
SmartyValidate::connect($tpl, true);
// Register some validators
SmartyValidate::register_validator('fnombre','uNom bre','notEmpty');
SmartyValidate::register_validator('fapellidos','u Apellidos','notEmpty');
// This TPL file contains the form elements and I include in a main file when action register is called from URL. For example: index.php?a=register
$tpl->assign('display','register');
} else {
SmartyValidate::connect($tpl);
// Check if form was validate or not
if(SmartyValidate::is_valid($_POST)) {
// If was then disconect from SmartyValidate
SmartyValidate::disconnect();
// Stop execution and send message
die('Form validate');
} else {
// If not redraw the form again
$tpl->assign($_POST);
// Redraw form and send message
print_r('Form not ok');
$tpl->assign('display','register');
}
}
$tpl->display('main.tpl');
$tpl->clear_all_assign();
?>

main.tpl:
---
{if $display eq ""}
{include file="home.tpl"}
{elseif $display eq "buy_now"}
{include file="buy_now.tpl"}
{elseif $display eq "register"}
{include file="register.tpl"}
{elseif $display eq "login"}
{include file="login.tpl"}
{/if}

This works fine, because when I call index.php?a=register register.tpl file is include, so I discard that this was the error.

register.tpl
---
<fieldset>
<legend>Registro de nuevos usuarios</legend>
<form name="uRegister" id="uRegister" method="post" action="uoptions.php?a=nuevo">
<table align="center" cellpadding="1" cellspacing="1">
<tr>
<td width="89" class="derecha">Nombre:</td>
<td width="144">
<input type="text" name="uNombre" id="uNombre" size="35" maxlength="35" value="{$uNombre}">
{validate id="fnombre" field="uNombre" message="El campo Nombre no puede estar vacio"}
</td>
</tr>
<tr>
<td class="derecha">Apellidos:</td>
<td>
<input type="text" name="uApellidos" id="uApellidos" size="35" maxlength="45" value="{$uApellidos}">
{validate id="fapellidos" field="uApellidos" message="El campo Apellidos no puede estar vacio"}
</td>
</tr>
<tr><td colspan="2" class="center"><input type="submit" name="btn_Send" value="Enviar"></td></tr>
</table>
</form>
</fieldset>

So I can't find the error, because all if in the same way you say me. I just change the example values from your code to match with my code. I check the session var and all are registered: form, validate criteria .... So can't really understand what I'm doing wrong.
Hint: I cut some code for do more readable and easy.

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...
  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 10h48.


É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,27743 seconds with 10 queries