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 ("}
// 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)
{
Echo ("message successful! ");
Printf ("<script language = 'javascript '> ");
Printf ("location = 'guestbook. php '");
Printf ("</script> ");
}
Else
{
Echo ("Message failed! ");
Printf ("<a href = 'javascript: history. back () '> return </a> ");
}
?>