Introduction: This is a detailed page of dedecms plug-in development tutorial. It introduces PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 325726 'rolling = 'no'>
This is a simple plug-in instance. With this plug-in, you can know how to develop a plug-in, how to set its structure, database, background, and so on.
File structure:
The enroll. php file is in the plus file.
The enroll.htm file is in the templets/plus folder.
The adenroll. php file is in the Dede folder.
Under the Dede/templet folder of the adenroll.html File
SQL file:
Create Table if not exists 'dede _ enroll' ('id' int (4) not null auto_increment, 'name' varchar (20) not null, 'mail' varchar (30) not null, 'tag' tinyint (1) not null default '0', primary key ('id') engine = InnoDB default charset = utf8 auto_increment = 1; insert into 'dede _ plus '('aid', 'plusname', 'menustring', 'mainurl', 'write', 'isshow ', 'filelist') values (30, 'register online ',' <m: item name = ''register online ''' link ='' adenroll. PHP ''rank = ''plus _ register online ''' target = ''main''/> ', '', 'g1000', 1 ,'');
For convenience, I have set two fields, name and email tag, to indicate whether admission 1 is admission.
The first insert statement is added to the background management.
The second insert statement is added to the foreground navigation bar.
Enroll. php
CopyCode
<? PHP // ******* must first contain common. inc. PHP then session_start (); otherwise, the session value cannot be obtained. // ******* because of common. inc. PHP configures the session path include_once dirname (_ file __). '. /.. /include/Common. inc. php'; // contains the configuration file session_start (); require_once dedeinc. "/arc. partview. class. PHP "; // contains the partiew class // ***** instantiate this class to obtain the header navigation bar and tail information. You can use dedetemplate if not required. class. PHP class $ Pv = new partview (); if ($ _ post) {If (checkemail ($ _ post ['mail']) = false) {// verify the mailbox The method is in common. func. PHP public function showmsg ('mailbox format error', '-1'); exit ();} if ($ _ post ['name'] = "") {showmsg ('user name cannot be blank ','-1'); exit () ;}else {$ name = htmlspecialchars ($ _ post ['name']);} if ($ _ session ['dd _ ckstr']! = Strtolower ($ _ post ['valider']) {// The verification code must be converted to lower-case showmsg ('verification code error',-1); exit ();} $ SQL = "insert into 'cms _ enroll' (name, mail) values ('$ name',' $ _ post [mail] ')"; // ********* $ the dedesql can be automatically instantiated by the system directly. class. PHP $ affected = $ db-> executenonequery2 ($ SQL); // execute a statement to return the impact value if ($ affected) {showmsg ('registration successful ', -1) ;}} else {$ PV-> settemplet (dedetemplate. '/plus/enroll.htm'); // set the template $ PV-> display (); // display page}?>
Enroll.htm
Copy code
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Adenroll. php
Copy code
<? PHP require_once (dirname (_ file __). '/config. PHP '); // The background configuration file checks the login configuration information require_once (dedeinc. "/datalistcp. class. PHP "); // contains the paging class if ($ _ Get ['action'] & $ _ Get ['id']) {if ($ _ Get ['action'] = 'pass ') {// various operations $ db-> executenonequery ("Update cms_enroll set 'tag' = 1 where id = '$ _ Get [ID]'"); showmsg ('admission successfully', 'adenroll. PHP ');} if ($ _ Get ['action'] = 'nopass ') {$ db-> executenonequery ("Update cms_enroll set 'tag' = 0 where id = '$ _ Ge T [ID] '"); showmsg ('cancel admission', 'adenroll. PHP ');} if ($ _ Get ['action'] = 'delete ') {$ db-> executenonequery ("delete from cms_enroll where id = '$ _ Get [ID]'"); showmsg ('deleted successfully', 'adenroll. PHP ') ;}} else {$ DL = new datalistcp (); $ DL-> pagesize = 10; // 10 $ DL-> settemplate ('. /templets/adenroll.htm '); // load the template $ SQL = "select * From cms_enroll"; $ DL-> setsource ($ SQL ); // The executed SQL statement cannot be reversed with $ DL-> settemplate $ DL-> display (); // display page}?>
Adenroll.html
Copy code
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
More articles on "dedecms plugin development tutorial"
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/325726.html pageno: 13.