Guestbook. php:
<Head>
<Meta http-equiv = "content-language" C>
<Meta http-equiv = "Content-Type" C>
<Title> </title>
<Style> A: link {
Color: #002878; text-Decoration: None
}
A: visited {
Color: #002878; text-Decoration: None
}
A: active {
Text-Decoration: None
}
A: hover {
Color: # cc1111; text-Decoration: None
}
P {
Color: #002878; font-size: 9pt
}
Table {
Color: #002878; font-size: 9pt
}
Li {
Color: #002878; font-size: 9pt; line-Height: 14pt
}
Ul {
Color: #002878; font-size: 9pt
}
}
</Style>
</Head>
<Body>
<Div align = "center">
<Center>
<Table border = "0" cellpadding = "0" cellspacing = "0" width = "574" Height = "312">
</Center>
<Tr>
<TD> <p align = "center"> Senior High <6> message book </br> </TD>
</Tr>
<Tr>
<TD width = "574" Height = "272" valign = "TOP">
<Form method = "Post" Action = "ly. php">
<Table border = "0" cellpadding = "0" cellspacing = "0" width = "100%">
<Center>
<Tr>
& Lt; TD width = "26%" align = "right" & gt;
Name: </TD>
<TD width = "74%"> <input style = "font-size: 9pt; width: 186; Background-color: # f8f8f8; Height: 19; Border: 1px solid #9a9999"
Type = "text" name = "T1" size = "13"> </TD>
</Tr>
<Tr>
& Lt; TD width = "26%" align = "right" & gt;
Email: </TD>
<TD width = "74%"> <input style = "font-size: 9pt; width: 186; Background-color: # f8f8f8; Height: 19; Border: 1px solid #9a9999 "name =" T2 "size =" 13 "> </TD>
</Tr>
<Tr>
& Lt; TD width = "26%" align = "right" & gt;
Personal Homepage: </TD>
<TD width = "74%"> <input style = "font-size: 9pt; width: 186; Background-color: # f8f8f8; Height: 19; Border: 1px solid #9a9999 "name =" T3 "size =" 13 "value =" http: // ";></TD>
</Tr>
<Tr>
& Lt; TD width = "26%" align = "right" & gt;
Topic: </TD>
<TD width = "74%"> <input style = "font-size: 9pt; width: 186; Background-color: # f8f8f8; Height: 19; Border: 1px solid #9a9999 "name =" T4 "size =" 13 "> </TD>
</Tr>
<Tr>
& Lt; TD width = "26%" align = "right" valign = "TOP" & gt;
Message: </TD>
<TD width = "74%"> <textarea style = "font-size: 9pt; width: 313; Background-color: # f8f8f8; Height: 177; Border: 1px solid #9a9999 "rows =" 10 "name =" S1 "Cols =" 45 "> </textarea> </TD>
</Tr>
<Tr>
<TD width = "100%" align = "right" colspan = "2">
</TD>
</Tr>
</Table>
<P align = "center">
<Input type = "Submit" value = "Submit" name = "B1"> <input type = "reset" value = "Rewrite" name = "B2"> </P>
</Form>
</Center>
</TD>
</Tr>
</Table>
<HR size = '1' color = '# 6666ff'>
</Div>
<Div align = "center">
<Center>
<Table border = "0" cellpadding = "0" cellspacing = "0" width = "603" Height = "294">
<Tr>
<TD width = "603" Height = "294">
<?
Include ("Connect. REC ");
$ QH = mysql_query ("select count (*) as rcnt from Guestbook ");
$ DATA = mysql_fetch_array ($ QH );
$ Nr = $ data ["rcnt"];
// Determine whether the offset parameter is passed to the script. If not, use the default value 0.
If (empty ($ offset ))
{
$ Offset = 0;
}
// Query result (20 entries per page, but you can change it by yourself)
// $ Result = mysql_query ("select * From guestbook order by time DESC limit $ offset, 5 ");
$ Result = mysql_query ("select * From guestbook limit $ offset, 5 ");
// Display the returned five records
While ($ DATA = mysql_fetch_array ($ result ))
{
Printf ("Name: <font color = '#000000'> % S </font> <br>", $ data ["name"]);
Printf ("Email: <font color = '# 3366ff'> % S </font> <br>", $ data ["mail"]);
Printf ("personal homepage: <font color = '# 3366ff'> % S </font> <br>", $ data ["url"]);
Printf ("from: <font color = '# 3366ff'> % S </font> <br>", $ data ["ip"]);
Printf ("message time: <font color = '# 3366ff'> % S </font> <br>", $ data ["time"]);
Printf ("Subject: <font color = '# 3366ff'> % S </font> <br>", $ data ["title"]);
Printf ("content: <font color = '#000000'> % S </font> <br>", $ data ["ly"]);
Printf ("<HR size = '1' color = '# 6666ff'> ");
}
// Next, write the link to another page
If ($ offset) // If the offset is 0, the link to the previous page is not displayed.
{
$ Preoffset = $ offset-5;
Print "<a href =" $ php_self? Offset = $ preoffset "> previous page </a> N ";
}
// Calculate the total number of required pages
$ Pages = Ceil ($ NR/5); // $ pages variable now contains the required page number
For ($ I = 1; $ I <= $ pages; $ I ++)
{
$ Newoffset = 5 * $ I-5;
Print "<a href =" $ php_self? Offset = $ newoffset "> $ I </a> N ";
}
// Check whether it is the last page
$ Next = $ Offset + 5;
If ($ next <$ nr)
{
Print "<a href =" $ php_self? Offset = $ next "> next page </a> N ";
}
Printf ("<a href = 'javascript: history. Back () '> return </a> ")
?>
</TD>
</Tr>
</Table>
</Center>
</Div>
</Body>
</Html>
Ly. php:
<?
Include ("Connect. REC ");
$ Name = $ T1;
$ Mail = $ T2;
$ Url = $ T3;
$ Title = $ T4;
$ Time = date ("Y-m-j h: I: s ");
$ IP = getenv ("remote_addr ");
$ Ly = $ S1;
$ result = mysql_query ("insert into guestbook (name, mail, URL, IP, time, title, ly) values ('$ name',' $ mail ', '$ url',' $ ip', '$ time',' $ title', '$ ly') ");
if ($ result = 1)
{< br> echo ("message successful! ");
printf (" ");
}< br> else
{< br> echo (" Message failed! ");
printf (" return ");
}< BR >?>