Develop a small message book using php + dbfile. Recently, I have been using php + dbfile to develop blogs. I learned a lot during the development process, so I tried to write a small message book. This message book uses php + dbfile and does not need to use a database. Recently, I have been using php + dbfile to develop a blog. I learned a lot during the development process, so I tried to write a small message book.
This message book using php + dbfile, do not need to use the database, can be used in the blog, such as http://www.customyze.com, this blog in the Tag Board is the message book.
The entire message book requires four files: board. php, index. php, config. php, and admin. php.
Board. php is used to store data. you can add a message record in it first. Code copy box
[Ctrl + A Select All and copy]
Index. php is the page for message display and submission. Code copy box
", $ Content); return $ content;} if ($ HTTP_SERVER_VARS ['request _ method'] = 'post') {$ configpath_parts1 = pathinfo ($ SCRIPT_FILENAME ); $ time = time (); $ name = $ HTTP_POST_VARS ['name']; $ url = (preg_match ("/^ [\ w-] + (\\. [\ w-] +) * @ [\ w-] + (\\. [\ w-] +) + $/I ", $ HTTP_POST_VARS ['URL'])
$ HTTP_POST_VARS ['URL'] = '')? $ HTTP_POST_VARS ['URL']: 'http: // '.html specialchars (preg_replace ("/https? \: \ // I ",'', $ HTTP_POST_VARS ['URL']), ENT_QUOTES); $ info = htmlencode ($ HTTP_POST_VARS ['info']); if ($ name! = ''& $ Info! = '') {$ Board [] = array ($ time, $ name, $ info, $ url);} for ($ I = 0; $ I "; $ Filename = $ configpath_parts1 ['dirname']. '/'. 'board. php'; if (is_writable ($ filename)
! File_exists ($ filename) {if (! $ Handle = fopen ($ filename, 'w') {return false;} if (! Fwrite ($ handle, $ content) {return false;} fclose ($ handle);} else {return false;} header ('Location :. ');} else {?> Message book
[Ctrl + A Select All and copy]
Config. php stores the password for managing the message book, and stores the password in a separate file for ease of modification. Code copy box
[Ctrl + A Select All and copy]
Admin. php is used to manage pages. It has simple functions and can only delete messages. You need to enter the management password when deleting the password and store it in config. php. Code copy box
1) {unset ($ Board [intval ($ HTTP_POST_VARS ['id']); for ($ I = 0; $ I "; $ Configpath_parts1 = pathinfo ($ SCRIPT_FILENAME); $ filename = $ configpath_parts1 ['dirname']. '/'. 'board. php'; if (is_writable ($ filename)
! File_exists ($ filename) {if (! $ Handle = fopen ($ filename, 'w') {return false;} if (! Fwrite ($ handle, $ content) {return false;} fclose ($ handle);} else {return false ;}} header ('Location: admin. php ');} else {?> Manage message Books
'. ($ Bd [3]! = ''? '':''). $ Bd [1]. ($ bd [3]! = ''? '':'').':'. $ Bd [2].' -'. Date ("G: I, M j, Y", $ bd [0]).' | '. (Count ($ Board)> 1? '
| ':'').'
'; Next ($ Board);} echo join ($ s, '');?>
[Ctrl + A Select All and copy]
This message book is still very simple and its functions are not perfect. for example, it can be improved without paging. :-)
Bytes. This message book uses php + dbfile and does not need to use a database ,...