SmartyValidate again

From: Date: Sun, 08 May 2005 21:49:41 +0000
Subject: SmartyValidate again
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-12595@lists.php.net to get a copy of this message
Hi list: Soury if I not understand but SmartyValidate bring some problems. The main problem is that not validate anything contain in a form. This is my php code ------------------------------------------------------ <?php session_start(); require(".././class/smarty/Smarty.class.php"); require(".././class/smarty/SmartyValidate.class.php"); include_once("../language/lang-spanish.php"); include('../class/adodb/adodb.inc.php'); include_once("../config.inc.php"); $template = & new Smarty(); /* Class smarty config */ $template->template_dir = "../themes/"; $template->compile_dir = "../themes/themes_c/"; $template->config_dir = "../themes/config/"; $template->compile_check = true; $template->display("admin_header.tpl"); $op = isset($_GET['op'])?$_GET['op']:"cursosadmin"; switch($op){ case "adicionar_curso": $template->assign("_TITULO",_TITULO); $template->assign("_ICONO",_ICONO); $template->assign("_IMAGEN",_IMAGEN); $template->assign("_DESCRIPCION",_DESCRIPCION); $template->assign("_ADICIONAR_NUEVO_CURSO",_ADICIONAR_NUEVO_CURSO); if(empty($_POST)) { SmartyValidate::connect($template,true); SmartyValidate::register_validator('titulo','titulo','notEmpty',false); SmartyValidate::register_validator('descripcion','descripcion','notEmpty',false); $template->display("admin_cursos_adicionar.tpl"); }else{ SmartyValidate::connect($template); if(SmartyValidate::is_valid($_POST)) { SmartyValidate::disconnect(); $template->display('admin_process.tpl'); // Paso 2 }else{ $template->assign($_POST); $template->display("admin_cursos_adicionar.tpl"); } } break; default: $template->display("admin_cursos.tpl"); break; } $template->display("admin_footer.tpl"); ?> ----------------------------------------------------------------------- And this is my tpl file: ----------------------------------------------------------------------- <form action="admin_data.php?mod=cursos&op=adicionar_curso" method="post" enctype="multipart/form-data" name="admin" id="admin"> <table width="60%" border="0" align="center" cellpadding="0" cellspacing="1" class="table"> <tr align="center"> <td colspan="2" class="th">{$_ADICIONAR_NUEVO_CURSO}</td> </tr> <tr> <td width="171" align="right" valign="top">{$_TITULO}</td> <td width="448"> <input name="titulo" type="text" size="50" maxlength="150" id="titulo" value="{$titulo|escape}"><br> {validate id="titulo" message='<span class="errorline">Debe introducir un título antes de continuar</span>'} </td> </tr> <tr> <td align="right" valign="top"> {$_ICONO}</td> <td><input name="icono" type="file" size="50" id="icono"></td> </tr> <tr> <td align="right" valign="top">{$_IMAGEN}</td> <td><input name="imagen" type="file" size="50" id="imagen"></td> </tr> <tr> <td align="right" valign="top">{$_DESCRIPCION}</td> <td> <textarea name="descripcion" cols="50" rows="8" wrap="VIRTUAL" id="descripcion">{$descripcion|escape}</textarea><br> {validate id="descripcion" message='<span class="errorline">Debe introducir una descripción antes de continuar</span>'} </td> </tr> <tr> <td colspan="2" align="center"><input name="envia" type="submit" id="envia" value="Insertar !!"></td> </tr> </table> </form> ------------------------------------------------------------------------ When I click in submit button the page is sent without check if values I can try to validate are empty or not. What's wrong? Regards Reynier Pérez Mira 3ero. Ing. Informática Entre más inteligente me siento, más me doy cuenta de lo ignorante que soy.

« previous php.smarty.general (#12595) next »