PHP + jQuery registration module improvement (3): Updated to Smarty3.1

Source: Internet
Author: User
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.