eval in smarty

From: Date: Wed, 14 Mar 2007 00:00:01 +0000
Subject: eval in smarty
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-13690@lists.php.net to get a copy of this message
Hi, I'm Wiwid, new member on here. I have the problem about eval function on smarty. Maybe someone can help me? OK, I explain the code: ************************************************************************ english.conf: ************************************************************************ register = "Register" username = "Username" password = "Password" password_confirm = "Password Confirmation" submit = "Submit" register_success = "Registration success" inputs_empty = "Please fill all the fields" password_not_match = "Password and password confirmation not match" ************************************************************************ function.php: ************************************************************************ class Customer { function register() { if(!empty($_POST['username_register']) && !empty($_POST['password_register']) && !empty($_POST['password2_register']) && ($_POST['password_register'] == $_POST['password2_register'])) { $command = "INSERT INTO customer SET username = '".$_POST['username_register']."', password = MD5('".$_POST['password_register']."')"; $query = mysql_query($command) or die("Can't insert registration data : " . mysql_error()); $message = "#register_success#"; } else if($_POST['password_register'] != $_POST['password2_register']) { $message = "#password_not_match#"; } else { $message = "#inputs_empty#"; } return $message; } } ************************************************************************ register.php: ************************************************************************ require_once("config.php"); // assumed database already connected from config.php require_once("function.php"); $smarty->config_load("english.conf"); $customer = new Customer; if(isset($_POST['username_register'])) { $message = $customer->register(); $smarty->assign("message", $message); } ************************************************************************ register.tpl: ************************************************************************ {if $smarty.post.username_register != ""} <table border="1" width="390"> <tr> <td align="left" colspan="2">{eval var=$message}</td> </tr> </table> {/if} <table border="1" width="390"> <form action="{$smarty.server.PHP_SELF}" method="post"> <tr> <td align="left" colspan="2">{#register#}</td> </tr> <tr> <td align="left">{#username#}</td> <td align="left"><input type="text" name="username_register" value="{$smarty.post.username_register}" /></td> </tr> <tr> <td align="left">{#password#}</td> <td align="left"><input type="password" name="password_register" /></td> </tr> <tr> <td align="left">{#password_confirm#}</td> <td align="left"><input type="password" name="password2_register" /></td> </tr> <tr> <td align="right" colspan="2"><input type="submit" name="submit" value="{#submit#}" /></td> </tr> </form> </table> ************************************************************************* When register.php run, I want the "message" text appear with one of these text: Registration success Please fill all the fields Password and password confirmation not match But I find the text appear as one of these: #register_success# #inputs_empty# #password_not_match# That's it. Thank you for help me. LuckyGuy354 IT Beginner http://www.wiwid.org

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