Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

SmartyValidate POST/GET

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
DumKopf
Smarty Rookie


Joined: 24 Sep 2007
Posts: 8

PostPosted: Mon Sep 24, 2007 5:30 am    Post subject: SmartyValidate POST/GET Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP