|
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 |
DumKopf Smarty Rookie
Joined: 24 Sep 2007 Posts: 8
|
Posted: Mon Sep 24, 2007 5:30 am Post subject: SmartyValidate POST/GET |
|
|
I'm trying to avoid the POST error when you refresh a page after submitting a form:
In PHP I used to just use:
Code: | header("location: login.php") |
to get back to the page without holding the POST information. Can't do that without maintaining the errors that SmartyValidate has identified.
This is what I have:
Code: | if(empty($_POST)) {
SmartyValidate::connect($smarty, true);
SmartyValidate::register_validator('sid','sales_id','notEmpty');
SmartyValidate::register_validator('pw','password','notEmpty');
$smarty->display('login.tpl');
} else {
SmartyValidate::connect($smarty);
// validate after a POST
if(SmartyValidate::is_valid($_POST)) {
// no errors, done with SmartyValidate
SmartyValidate::disconnect();
header("location: index.php");
} else {
// error, redraw the form
$smarty->assign($_POST);
$smarty->display('login.tpl'); //cannot use header("location: login.php"); here without loss of errors
}
} |
Any ideas? I'm pretty new with Smarty/SmartyValidate, so go easy if I'm just going about things wrong.[/code] |
|
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
|