Passing variables from form to form

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
TylerK
New Member
New Member
Posts: 3
Joined: Fri Sep 05, 2008 7:19 pm

Passing variables from form to form

Post by TylerK »

Hello!

I'm currently working on a site for for a small insurance agency and they have a 'enter your zip and get a quote' form input on the homepage and subpages, what I am trying to accomplish is getting that zip code to pass into the quote form on another page.

I've setup a test here, and it's simple enough to get working in regular old php, but I for the life of me haven't been able to figure out how to get this simple function -

Code: Select all

<?php 
     $zip = $_POST['zip']; 
     echo "<input type=\"text\" value=\"$zip\" >"; 
?> 
To work inside {php} tags. (They're turned on in the config.php)

Any help would be greatly appreciated as I'm at my wits end on this one. Thanks in advance!
User avatar
Augustas
Forum Members
Forum Members
Posts: 241
Joined: Wed Oct 17, 2007 6:09 pm
Location: the world

Re: Passing variables from form to form

Post by Augustas »

You can access your POST or GET variables with the Smarty, so you do not have to enable {php} tags.

Access your ZIP code like this:

Code: Select all

{$smarty.request.zip}
or

Code: Select all

{$smarty.post.zip}
Read more about this in Smarty documentation:

Code: Select all

{* display value of page from URL ($_GET) http://www.example.com/index.php?page=foo *}
{$smarty.get.page}
{* display the variable "page" from a form ($_POST['page']) *}
{$smarty.post.page}
{* display the value of the cookie "username" ($_COOKIE['username']) *}
{$smarty.cookies.username}
{* display the server variable "SERVER_NAME" ($_SERVER['SERVER_NAME'])*}
{$smarty.server.SERVER_NAME}
{* display the system environment variable "PATH" *}
{$smarty.env.PATH}
{* display the php session variable "id" ($_SESSION['id']) *}
{$smarty.session.id}
{* display the variable "username" from merged get/post/cookies/server/env *}
{$smarty.request.username}
http://FollowTheRoad.com/ - living on the road...
http://www.kligys.com/ - asmeninis blog'as...
TylerK
New Member
New Member
Posts: 3
Joined: Fri Sep 05, 2008 7:19 pm

Re: Passing variables from form to form

Post by TylerK »

Oh Brilliant! It worked perfectly, thank you very much!

I think I'm going to spend the weekend reading the smarty resources site, thanks again :)
User avatar
Augustas
Forum Members
Forum Members
Posts: 241
Joined: Wed Oct 17, 2007 6:09 pm
Location: the world

Re: Passing variables from form to form

Post by Augustas »

Or you can just download Smarty documentation PDF:
http://www.smarty.net/download-docs.php
http://FollowTheRoad.com/ - living on the road...
http://www.kligys.com/ - asmeninis blog'as...
Post Reply

Return to “Developers Discussion”