File Upload in PEAR and Smarty

For uploading files, you need to install a package of PEAR called ‘HTTP_Upload’ along with the installation of PEAR and Smarty. HTTP_Upload is used for easy and secure managment of files submitted via HTML forms. This package provides an advanced system for managing uploads of files via HTML input type “file” fields. Features include: 1) … Read more

Pagination in PEAR and Smarty

First of all, you need to install PEAR in your web server. Then you need to install Smarty. After that, you need to install a package in PEAR. It’s called ‘Pager’. Pager is a class to page an array of data. It is taken as input and it is paged according to various parameters. Pager … Read more

Using database in PEAR and Smarty

For using database, you need to install a package of PEAR called ‘MDB2’ along with the installation of PEAR and Smarty. MDB2 provides a common API for all support RDBMS. Connecting to database To instantiate a database object you have several methods available using MDB2. factory(): Will instantiate a new MDB2_Driver_Common instance, but will not … Read more

Smarty: Selection list using foreach and section loop

In this article, I will be explaining about foreach and section loop used in Smarty. I will be using these loops for creating a selection list. We can create selection list from a custom Smarty function html_options. <select name="user"> {html_options values=$id output=$names selected="4"} </select> Instead of html_options, we can also use loops to create the … Read more

Smarty: Include header and footer template

In previous article, I had written about installing and using Smarty. In this article, I will be showing how you can include header and footer in Smarty. index.php assigns contents and calls the template file index.tpl <?php require_once('classes/ConnectSmarty.class.php'); // create an object of the class included above $smarty = new ConnectSmarty; // assign content $smarty->assign('name','Mukesh … Read more

Smarty Template Engine: How to install and use? [BEGINNER’S GUIDE]

In this article, I will be introducing how to use Smarty Template engine. This is a beginner tutorial. First of all, you need to download Smarty from http://www.smarty.net/download. You can follow a quickstart guide from here as well: http://www.smarty.net/quick_install. My approach of coding is a bit different than the quickstart guide present on smarty website. … Read more