Home > Archive > PHP Smarty Templates > January 2006 > RE: [SMARTY] SmartyValidate 2.6 and Smarty 2.6.12 doesn't work ...
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
RE: [SMARTY] SmartyValidate 2.6 and Smarty 2.6.12 doesn't work ...
|
|
| Reynier Perez Mira 2006-01-30, 7:05 pm |
| Oww !!!!!, ... This is very help to me because I not understand yet how =
SmartyValidate works. Now I got. The problems in my code still appear.=20
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('fnom
bre','uNombre','notEmpty');
=
SmartyValidate::register_validator('fape
llidos','uApellidos','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=3Dregister
$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=20
die('Form validate');
} else {
// If not redraw the form again
$tpl->assign($_POST);
// Redraw form and send message=20
print_r('Form not ok');
$tpl->assign('display','register');
}
}
$tpl->display('main.tpl');
$tpl->clear_all_assign();
?>
main.tpl:
---
{if $display eq ""}
{include file=3D"home.tpl"}
{elseif $display eq "buy_now"}
{include file=3D"buy_now.tpl"}
{elseif $display eq "register"}
{include file=3D"register.tpl"}
{elseif $display eq "login"}
{include file=3D"login.tpl"}
{/if}
This works fine, because when I call index.php?a=3Dregister register.tpl =
file is include, so I discard that this was the error.
register.tpl
---
<fieldset>
<legend>Registro de nuevos usuarios</legend>
<form name=3D"uRegister" id=3D"uRegister" method=3D"post" =
action=3D"uoptions.php?a=3Dnuevo">
<table align=3D"center" cellpadding=3D"1" cellspacing=3D"1">
<tr>
<td width=3D"89" class=3D"derecha">Nombre:</td>
<td width=3D"144">
<input type=3D"text" name=3D"uNombre" id=3D"uNombre" size=3D"35" =
maxlength=3D"35" value=3D"{$uNombre}">
{validate id=3D"fnombre" field=3D"uNombre" message=3D"El campo =
Nombre no puede estar vacio"}
</td>
</tr>
<tr>
<td class=3D"derecha">Apellidos:</td>
<td>
<input type=3D"text" name=3D"uApellidos" id=3D"uApellidos" =
size=3D"35" maxlength=3D"45" value=3D"{$uApellidos}">
{validate id=3D"fapellidos" field=3D"uApellidos" message=3D"El =
campo Apellidos no puede estar vacio"}
</td>
</tr>
<tr><td colspan=3D"2" class=3D"center"><input type=3D"submit" =
name=3D"btn_Send" value=3D"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.=20
Regards
ReynierPM
4to. a=F1o Ing. Inform=E1tica
Usuario registrado de Linux: #310201
****************************************
*********************************=
El programador superh=E9roe aprende de compartir sus conocimientos.=20
Es el referente de sus compa=F1eros. Todo el mundo va a preguntarle y =
=E9l, secretamente, lo fomenta porque es as=ED como adquiere su =
legendaria
sabidur=EDa: escuchando ayudando a los dem=E1s...=20
| |
| Monte Ohrt 2006-01-30, 7:05 pm |
| // 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 help 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('fnom
bre','uNombre','notEmpty');
> SmartyValidate::register_validator('fape
llidos','uApellidos','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 d
oing 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!
>
>
>
>
|
|
|
|
|