|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
thiebo Smarty Pro
Joined: 16 Jan 2005 Posts: 144 Location: Paris
|
Posted: Sat Jan 29, 2005 4:47 pm Post subject: validates but doesn't show success.tpl |
|
|
Hello,
I have just installed SmartyValidate and it seems great to me and I am testing it with the files provided by the README (index.php, form.tpl and success.tpl) I just have a quite important problem : it verifies the criteria all right and sends the correct message when criteria are not met, but once the form is completed, and I try to validate it, it does not show success.tpl
Here's my index.php :
[php:1:92399eb339]<?php
session_start();
// you will need to setup Smarty if
// the defaults are not correct.
require ('/usr/local/lib/php/Includes/smartysite/setup.php');
require('SmartyValidate.class.php');
$smarty = &new Smarty_smartysite;
// required initialization
SmartyValidate::connect($smarty);
if(empty($_POST)) {
$smarty->display('/var/www/html/smarty/templates/form.tpl');
} else {
// validate after a POST
if(SmartyValidate::is_valid($_POST)) {
// no errors, done with SmartyValidate
SmartyValidate::disconnect();
$smarty->display('success.tpl');
} else {
// error, redraw the form
$smarty->assign($_POST);
$smarty->display('form.tpl');
}
}
?>
?>[/php:1:92399eb339]
and form.tpl :
Code: | <HTM><HEAD><TITLE>TEST</TITLE></HEAD>
<BODY>
<form method="post" action="index.php">
{validate field="FullName" criteria="notEmpty" transform="trim" message="Full Name Cannot Be Empty"}
Full Name: <input type="text" name="FullName" value="{$FullName|escape}"><br />
{validate field="Phone" criteria="isNumber" empty="yes" transform="trim" message="Phone Number Must be a Number"}
Phone :<input type="text" name="Phone" value="{$Phone|escape}" empty="yes"><br />
{validate field="Email" criteria="isEmail" transform="trim" message="Email not valid"}
Email: <input type="text" name="Email" size="30" value="{$Email|escape}"><br />
{validate field="Date" criteria="isDate" empty="true" transform="trim" message="Date not valid"}
Date: <input type="text" name="Date" size="10" value="{$Date|escape}"><br />
{validate field="password" criteria="isEqual" field2="password2" message="passwords do not match"}
password: <input type="password" name="password" size="10" value="{$password|escape}"><br />
password2: <input type="password" name="password2" size="10" value="{$password2|escape}"><br />
<input type="submit">
</form>
</BODY>
</HTML> |
I probably has to do with my error messages :
These messages are really funny since SmartyValidate.class.php and index.php do not contain the words prenom, email and nom.... Those are used in another form I use.
Does anyone have a clue what I did wrong ?
Thanks,
Thiebo |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|