This article is the third article on improvement of the PHP + jQuery registration module. it mainly records the update of Smarty to the latest version 3.1. it is a very useful article. if you need it, refer to jQuery.
Smarty3.1X (the latest version 3.1.19) has many features modified compared with Smarty2.x. I modified this module again using Smarty3.1.18 (http://www.smarty.net/files/Smarty-3.1.18.zip), and the project files and directories looked cleaner and more conditioned.
Copy the libs folder in the Smarty package to the module root directory, and then create init. inc. php in the root directory:
The code is as follows:
<? Php
/**
File: init. inc. php Smarty object instantiation and initialization file
*/
/********************** Smarty settings *************** *********/
// Root directory path method, used for Smarty setting
Define ("ROOT", str_replace ("\", "/", dirname (_ FILE __))."/");
Require ROOT. 'libs/Smarty. class. php ';
$ Smarty = new Smarty ();
// Set the default path for Smarty3
$ Smarty-> setTemplateDir (ROOT. 'Templates /')
-> SetCompileDir (ROOT. 'Templates _ c /')
-> SetPluginsDir (ROOT. 'ins ins /')
-> SetCacheDir (ROOT. 'cache /')
-> SetConfigDir (ROOT. 'configs ');
$ Smarty-> caching = false;
$ Smarty-> cache_lifetime = 60*60*24; // The template cache validity period is 1 day.
$ Smarty-> left_delimiter = '<{';
$ Smarty-> right_delimiter = '}> ';
/*************************************** ********************/
// Root Directory url
$ PHP_SELF = $ _ SERVER ['php _ SELF '];
$ ROOT_URL = 'http ://'. $ _ SERVER ['http _ host']. substr ($ PHP_SELF, 0, strrpos ($ PHP_SELF, '/') + 1 );
Define (ROOT_URL, $ ROOT_URL );
// Template Directory url
Define ("Template_Dir", $ ROOT_URL. 'templates ');
Create the templates, templates_c, plugins, cache, and configs folders in the initialization file.
The modified files are all relatively different, and the modified register.html and register. php files are listed here.
Register.html is the registration front-end page, Path is/templates/register.html
The code is as follows:
Registration page