Message book part:
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 "<a href = '../index. php'> Please register again <br> ";
Exit;
}
?>
<HTML>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Title> message book </title>
<Style type = "text/CSS">
<! --
. Blue9 {font-size: 9pt; color: # 0099ff; text-Decoration: None}
. Black9 {font-size: 9pt; text-Decoration: None}
. Purple10 {font-size: 10pt; color: # 9900ff; text-Decoration: None}
. White12 {font-size: 12pt; color: # ffffff; text-Decoration: None}
A: visited {color: # ffffff}
A: link {color: # ffffff}
-->
</Style>
</Head>
<Body bgcolor = "# ffffff">
<? PHP
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
?>
<Table width = "98%" border = "0" cellspacing = "0" cellpadding = "0" Height = "61">
<Tr>
<TD Height = "62" width = "34%"> </TD>
& Lt; TD Height = "62" width = "66%" & gt;
<Div align = "center"> </div>
</TD>
</Tr>
</Table>
<Table width = "95%" border = "1" cellspacing = "0" cellpadding = "0" Height = "253" bordercolordark = "# ffffff" bordercolorlight = "#003399" align = "center">
<Tr>
& Lt; TD Height = "250" & gt;
<Div align = "center"> </div>
<Table width = "95%" border = "0" cellspacing = "0" cellpadding = "0" Height = "32" bgcolor = "# 3366ff">
<Tr>
<TD width = "26%" class = "white12" Height = "23"> <a href = ".. /guest. PHP "class =" white12 "> homepage </a>
> Message book </TD>
<TD width = "48%" class = "white12" Height = "23">
<? PHP
Echo "Total number of posts:", $ Max, "No ";
For ($ n = 1; $ n <= $ P; $ n ++ ){
Echo "<a href = index. php? Page = $ n> $ n </a> ";
}
Echo "page ";
?>
</TD>
<TD width = "15%" Height = "23"> <a href = "addnote. PHP "> </a> </TD>
<TD width = "11%" Height = "23"> <a href = "delnote. PHP "> <SPAN class =" white12 "> Message Management </span> </a> </TD>
</Tr>
</Table>
<? PHP
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 "<Table width = '000000' border = '0' cellspacing = '0' cellpadding = '0' Height = 100% 'bordercolor = '# ffff'> <tr bgcolor =' # eeeeee '> ";
Echo "<TD width = '000000' Height = '33' bgcolor = '# eeeeee' class = 'blue9'> </TD> ";
Echo "<TD width = '000000' Height = '33' bgcolor = '# eeeeee' class = 'blue9'> contact: $ name </TD> ";
Echo "<TD width = '000000' Height = '33' bgcolor = '# eeeeee' class = 'blue9'> published at: $ time </TD> ";
Echo "<TD width = '000000' Height = '33' bgcolor = '# eeeeeee' class = 'blue9'> <a href = 'mailto: $ email '> </a> </TD> ";
Echo "<TD width = '000000' Height = '33' class = 'blue9'> $ IP </TD> </tr> <tr> ";
Echo "<TD colspan = '5' class = 'purple10' Height = '33'> title: $ title </TD> </tr> ";
Echo "<tr bgcolor = '# ffff'> <TD colspan = '5' class = 'black9' Height = '37'> message content: $ Nnote <br> -------------------- <br> $ signature </TD> </tr> </table> ";
}
Mysql_close ($ dB );
?>
</TD>
</Tr>
</Table>
</Body>
</Html>
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 "<a href = '../index. php'> Please register again <br> ";
Exit;
}
?>
<HTML>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Title> Add a message </title>
<Style type = "text/CSS">
<! --
. White12 {font-size: 12pt; color: # ffffff; text-Decoration: None}
-->
</Style>
</Head>
<Body bgcolor = "# ffffff">
<Table width = "98%" border = "0" cellspacing = "0" cellpadding = "0" Height = "61">
<Tr>
<TD Height = "62" width = "34%"> </TD>
& Lt; TD Height = "62" width = "66%" & gt;
<Div align = "center"> </div>
</TD>
</Tr>
</Table>
<? PHP
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 to <br>.
If (! $ Title |! $ Nnote) {// check whether it is complete
Echo "Sorry, you must fill in all content! <Br> "." <a href = 'javascript: history. Back () '> return </a> ";
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! ";
}
?>
<Table width = "99%" border = "1" cellspacing = "0" cellpadding = "0" align = "center" bordercolor = "# 3366ff">
<Tr bgcolor = "# 3366ff">
<TD width = "81%" class = "white12" Height = "26"> <a href = ".. /.. /main. PHP "class =" white12 "> homepage </a>
> <A href = "index. php" class = "white12"> guestbook </a> Add a message </TD>
<TD width = "19%" class = "white12" Height = "26"> <a href = 'index. php' class = "white12"> View comments </a>
</TD>
</Tr>
<Tr>
<TD colspan = "2">
<Form name = "form1" method = "Post" Action = "addnote. php">
<Table width = "99%" border = "0" cellspacing = "0" cellpadding = "0">
<Tr>
<TD>
<Div align = "center"> title <br>
<Input type = "text" name = "TOP" size = "50">
<Br>
Content <br>
<Textarea name = "content" Cols = "50" rows = "6"> </textarea>
<Br>
<Input type = "Submit" name = "Submit" value = "OK">
<Input type = "reset" name = "cancel" value = "Rewrite">
</Div>
</TD>
</Tr>
</Table>
</Form>
</TD>
</Tr>
</Table>
<P> <a href = "Main. php? User = <? Echo $ user?> "Class =" white12 "> <br>
</A> </P>
</Body>
</Html>