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

Easy way to assign form post to next template

 
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 -> Tips and Tricks
View previous topic :: View next topic  
Author Message
dubhunter
Smarty Rookie


Joined: 09 Aug 2007
Posts: 13
Location: Santa Monica, CA

PostPosted: Thu Aug 09, 2007 5:18 pm    Post subject: Easy way to assign form post to next template Reply with quote

This is a great one when server side validation is need, or you would like to forward to a thank you page.

Code:

//method from PageController Class

private function assignPost($args)
{
   $this->smarty->caching = false;
   foreach ($args as $k => $v)
      $this->smarty->assign($k, stripslashes($v));
}

//USAGE:
//$this->assignPost($_POST);
Back to top
View user's profile Send private message Visit poster's website
Celeb
Administrator


Joined: 17 Apr 2007
Posts: 1025
Location: Vienna

PostPosted: Fri Aug 10, 2007 6:19 am    Post subject: Reply with quote

What's wrong with
Code:
$smarty->assign($_POST)

What do you need the stripslashes() for? I know its function but why do you need it here in particular?
_________________
Darn computers always do what I tell them to instead of what I want them to do.
Back to top
View user's profile Send private message
dubhunter
Smarty Rookie


Joined: 09 Aug 2007
Posts: 13
Location: Santa Monica, CA

PostPosted: Fri Aug 10, 2007 7:00 am    Post subject: Reply with quote

Celeb wrote:
What's wrong with
Code:
$smarty->assign($_POST)

What do you need the stripslashes() for? I know its function but why do you need it here in particular?


You are right. There is nothing wrong with it. I was not aware that associative arrays were available in any context besides
Code:
{$foo.no}, {$foo.label}
{$contact.id}, {$contact.name},{$contact.email}


The stripslashes() was in there for magic_quotes_gpc being on in the .ini file.
_________________
http://dontblinkdesign.com
Back to top
View user's profile Send private message Visit poster's website
Celeb
Administrator


Joined: 17 Apr 2007
Posts: 1025
Location: Vienna

PostPosted: Fri Aug 10, 2007 7:54 am    Post subject: Reply with quote

I usually use the above line when validating HTML forms with SmartyValidate and I've got magic_quotes_gpc on too.
Works like a charm Smile You just gotta love Smarty Smile
_________________
Darn computers always do what I tell them to instead of what I want them to do.
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sat Aug 11, 2007 2:30 am    Post subject: Reply with quote

magic quotes === evil
Back to top
View user's profile Send private message
Celeb
Administrator


Joined: 17 Apr 2007
Posts: 1025
Location: Vienna

PostPosted: Sat Aug 11, 2007 9:22 am    Post subject: Reply with quote

Aye .. it's not my call though.
_________________
Darn computers always do what I tell them to instead of what I want them to do.
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 -> Tips and Tricks 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