Part of the Xinlin transcript (7) message book:
Class Member message book: show message: class/notebook/index. php
Session_start (); // start session
If (! Session_is_registered ("userregister") | ($ userregister = "") // check whether it is registered. if userregister is not registered or the session is null, register it again.
{
Echo "please register again
";
Exit;
}
?>
Message book
Include ("../config. php ");
$ Result = mysql_query ("SELECT * FROM notebook", $ db );
$ Row = mysql_num_rows ($ result); // You can check the number of rows in the query result.
$ Max = $ row; // total number of posts
// Set 10 entries per page. you can set the total number of pages on $ p, the number of pages on $ page, and the number of rows on $ low.
If (! $ Page) {$ page = 1;} // The default value of $ page is 1.
$ P = ceil ($ max/10); // The maximum number of pages is the maximum integer of $ max/10.
$ Low = 10 * ($ page-1 );
If ($ page = $ p & ($ max % 10) <> 0) {$ x = ($ max % 10);} else {$ x = 10 ;} // if the last page is not an integer multiple of 10, read the remainder of $ max divided by 10. Otherwise, take 10.
If ($ max = 0) {$ x = 0;} // if there is no post, set $ x to 0.
$ Result = mysql_query ("select * from notebook order by time DESC limit $ low, $ x", $ db); // query BY post time in descending ORDER
?>
Homepage > Message book |
Echo "total number of posts:", $ max, "no "; For ($ n = 1; $ n <= $ p; $ n ++ ){ Echo "$ n "; } Echo "page "; ?> |
|
Message Management |
For ($ I = 0; $ I <= ($ X-1); $ I ++ ){ $ User = mysql_result ($ result, $ I, 'User '); $ Time = mysql_result ($ result, $ I, 'time '); $ Ip = mysql_result ($ result, $ I, 'IP '); $ Title = mysql_result ($ result, $ I, 'title '); $ Nnote = mysql_result ($ result, $ I, 'note '); $ Yresult = mysql_query ("SELECT * FROM user where user = '$ user'", $ db); // read the member database $ Name = mysql_result ($ yresult, 0, 'name '); $ Signature = mysql_result ($ yresult, 0, 'signature'); // read the personal signature $ Email = mysql_result ($ yresult, 0, 'Email '); $ Face = mysql_result ($ yresult, 0, 'face '); $ Face = '../image/face/icon'. $ face;
Echo"
";Echo"
| ";Echo"
Contact: $ name | ";Echo"
Posted at: $ time | ";Echo"
| ";Echo"
$ Ip |
";Echo"
Title: $ title |
";Echo"
Message content: $ nnote ---------------------- $ Signature |
"; } Mysql_close ($ db ); ?> |
Add message: class/notebook/addnote. php
Session_start (); // start session
If (! Session_is_registered ("userregister") | ($ userregister = "") // check whether it is registered. if userregister is not registered or the session is null, register it again.
{
Echo "please register again
";
Exit;
}
?>
Add message
Include ("../config. php ");
If ($ submit ){
$ Time = date ("Y, m, d, H: I: s ");
$ Ip = $ REMOTE_ADDR; // The ip address of the contact.
$ Title = strip_tags ($ top );
$ Nnote = nl2br (strip_tags ($ content); // remove the html tag and convert the linefeed
.
If (! $ Title |! $ Nnote) {// check whether it is complete
Echo "Sorry, you must fill in all content!
"." Back ";
Exit ;}
// Write data to the database
$ SQL = "INSERT INTO notebook (user, time, ip, title, nnote) VALUES ('$ userregister', '$ time',' $ IP', '$ title ', '$ nnote ')";
$ Result = mysql_query ($ SQL, $ db );
Mysql_close ($ db );
Echo "message successful! ";
}
?>
Homepage > Message book> add a message |
View messages |
|
"Class =" white12 ">