I don't get the passing data process...
| From: | Luc Saint-Elie | Date: | Sun, 29 Apr 2001 08:26:48 +0000 |
| Subject: | I don't get the passing data process... | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-644@lists.php.net to get a copy of this message | ||
Hello,
First I re-apologies for all my newbie questions that could probably seem very basic if not annoying for some highly skilled people here, but there is a huge gap between the theorical functionality and its real life application.
As an excuse I promise that when my site will be finished I'll write down some kind of beginner FAQ to avoid other newcomers to fall in the same holes ;-))
Today's question is :
How to send back data to a Smarty generated page after data have been processed ?
The context : the index.php file generates a page from a template (index.tpl) , this template been formed of other templates displayed according to the visitor choice.
For example the main page can display an article (in this case the central part of the pages includes a template that displays an article) it can display a registration form (in this case the central part on the main page include a template that display a registration form) and so on
the choice of the template included by the main template is driven by a op= processed by a {if} statement in the main template
===== index.tpl (main template) ======
[..some fix HTML stuff..]
{if $op eq "news"}
{include file="news.tpl"}
{elseif $op eq "chat"}
{include file="irc.tpl"}
{elseif $op eq "enregistrement"}
{include file="register.tpl"}
{elseif $op eq "registerok"}
{include file="register_done.tpl"}
{elseif $op eq "registererror"}
{include file="register_error.tpl"}
{else}
{include file="article.tpl"}
{/if}
[..some fix HTML stuff..]
=============================
In the case of the registration form (register.tpl) if the user fills it and click "send" the data is sent to a bunch of files to process, verify generate email messages, fill the temporary table in the database.. all the usual registration stuff.
Then a message is sent back to the user
- is the registration process is ok the message contains the registered data to inform what has been recorded (through the display of register_done.tpl inside index.tpl)
- if the registration process failed, the message contains an explanation about what failed (through the display of register_erro.tpl inside index.tpl)
To do that the processing files must send back to the originating page (index.php) a set of data
I succeed in doing that the wrong way (by adding data in the url)
I fail doing that the normal way
I mean
if, from my processing page I do (WRONG way)
================================
if ($reponse == 2) {
header("Location: http://test.domain.com/index.php?op=registerok&username=$username&password=$password&name=$name&email=$email&age=$age&sex=$sex&description=$description&url=$url");
================================
It is ok, the index.php file display the index.tpl template with the right include (register_done.tpl) that displays the registered data.
If in my processing page I do (more logical way.. but clearly wrong also because it doesn't work)
==================================
: if ($reponse == 2) {
$op = 'registerok';
header("Location: http://test.bdsmfr.com/index.php");
===================================
It is not ok, the index.php file display the index.tpl template in its standard form (include file="article.tpl") so apparently the 'op' switch is not taken in account
All values have been "assigned" in index.php
=====================
// fait suivre le selecteur de page
$template->assign("op",$op);
// variables spécifiques à register.php
$template->assign("raison",$raison);
$template->assign("reponse",$reponse);
$template->assign("name",$name);
$template->assign("email",$email);
$template->assign("age",$age);
$template->assign("sex",$sex);
$template->assign("username",$username);
$template->assign("password",$password);
$template->assign("fmail",$fmail);
$template->assign("description",$description);
$template->assign("url",$url);
=======================
Luc