For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > December 2006 > howto handle formdata with smarty?!









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author howto handle formdata with smarty?!
Tamer Higazi

2006-12-03, 8:04 am

Hi people!
I have problems handling formdata with smarty. The template with
"formular.tpl" is a small html template with a form itself and
"formular.php" is the script!

Can somebody help me?!

Tamer

formular.tpl:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Tabelle mit Werten...</title>
<meta name="generator" content="Bluefish 1.0.7">
<meta name="author" content="Tamer Higazi">
<meta name="date" content="2006-12-03T10:21:43+0200">
<meta name="copyright" content="">
<meta name="keywords" content="">
<meta name="description" content="">
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<pre>
<form method="POST" enctype="text/plain" target="_self"
action="formular.php">
<input type="text" name="number1" size="20" maxlength="20">
<input type="text" name="number2" size="20" maxlength="20">
<input type="text" name="number3" size="20" maxlength="20">
<input type="submit" name="los" value="Hau drauf!">

</form>
{$var11}
{$var12}
{$var13}
</pre>
</body>
</html>

formular.php:

<?php
require_once('Smarty/Smarty.class.php');

$smarty = new Smarty();
$smarty->template_dir = '/home/tamer/public_html/smarty/templates';
$smarty->compile_dir = '/home/tamer/public_html/smarty/templates_c';
$smarty->cache_dir = '/home/tamer/public_html/smarty/cache';
$smarty->config_dir = '/home/tamer/public_html/smarty/configs';
$smarty->caching = false;
$smarty->force_compile = true;

$index1 = $_REQUEST["number1"];
$index2 = $_REQUEST["number2"];
$index3 = $_REQUEST["number3"];

$smarty->assign('var1',$index1);
$smarty->assign('var2',$index2);
$smarty->assign('var3',$index3);
$smarty->display('formular.tpl');
?>
Pedro

2006-12-03, 7:08 pm

The $vars in the template are numbered 11,12,13 and not 1,2,3 ;-)

> $smarty->assign('var1',$index1);
> $smarty->assign('var2',$index2);
> $smarty->assign('var3',$index3);


> {$var11}
> {$var12}
> {$var13}


pete

Tamer Higazi wrote:
> Hi people!
> I have problems handling formdata with smarty. The template with
> "formular.tpl" is a small html template with a form itself and
> "formular.php" is the script!
>
> Can somebody help me?!
>
> Tamer
>
> formular.tpl:
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> <html>
> <head>
> <title>Tabelle mit Werten...</title>
> <meta name="generator" content="Bluefish 1.0.7">
> <meta name="author" content="Tamer Higazi">
> <meta name="date" content="2006-12-03T10:21:43+0200">
> <meta name="copyright" content="">
> <meta name="keywords" content="">
> <meta name="description" content="">
> <meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
> <meta http-equiv="content-type" content="text/html; charset=UTF-8">
> </head>
> <body>
> <pre>
> <form method="POST" enctype="text/plain" target="_self"
> action="formular.php">
> <input type="text" name="number1" size="20" maxlength="20">
> <input type="text" name="number2" size="20" maxlength="20">
> <input type="text" name="number3" size="20" maxlength="20">
> <input type="submit" name="los" value="Hau drauf!">
>
> </form>
> {$var11}
> {$var12}
> {$var13}
> </pre>
> </body>
> </html>
>
> formular.php:
>
> <?php
> require_once('Smarty/Smarty.class.php');
>
> $smarty = new Smarty();
> $smarty->template_dir = '/home/tamer/public_html/smarty/templates';
> $smarty->compile_dir = '/home/tamer/public_html/smarty/templates_c';
> $smarty->cache_dir = '/home/tamer/public_html/smarty/cache';
> $smarty->config_dir = '/home/tamer/public_html/smarty/configs';
> $smarty->caching = false;
> $smarty->force_compile = true;
>
> $index1 = $_REQUEST["number1"];
> $index2 = $_REQUEST["number2"];
> $index3 = $_REQUEST["number3"];
>
> $smarty->assign('var1',$index1);
> $smarty->assign('var2',$index2);
> $smarty->assign('var3',$index3);
> $smarty->display('formular.tpl');
> ?>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com