I wrote a message with Php+mysql.
Last Update:2017-02-28
Source: Internet
Author: User
guestbook.php:
<meta http-equiv= "Content-language" content= "ZH-CN" >
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<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>
<body>
<div align= "center" >
<center>
<table border= "0" cellpadding= "0" cellspacing= "0" width= "574" height= "312" >
</center>
<tr>
<td><p align= "center" > Senior <6> Class 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>
<TD width= "26%" align= "right" >
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= "></td>"
</tr>
<tr>
<TD width= "26%" align= "right" >
Email:</td>
<TD width= "74%" ><input style= "font-size:9pt"; width:186; Background-color: #f8f8f8; height:19; border:1px solid #9a9999 "name=" T2 "size=" ></td>
</tr>
<tr>
<TD width= "26%" align= "right" >
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=" value= "http://" ></td>
</tr>
<tr>
<TD width= "26%" align= "right" >
Theme:</td>
<TD width= "74%" ><input style= "font-size:9pt"; width:186; Background-color: #f8f8f8; height:19; border:1px solid #9a9999 "name=" T4 "size=" ></td>
</tr>
<tr>
<TD width= "26%" align= "right" valign= "top" >
Message:</td>
<TD width= "74%" ><textarea style= "font-size:9pt"; width:313; Background-color: #f8f8f8; height:177; border:1px solid #9a9999 "rows=" name= "S1" cols= "></textarea></td>"
</tr>
<tr>
<TD width= "100%" align= "right" colspan= "2" >
</td>
</tr>
</table>
<p align= "center" >
<input type= "Submit" value= "submitted" name= "B1" > <input type= "reset" value= "rewrite" name= "B2" ></p>
</form>
</center>
</td>
</tr>
</table>
</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 if the offset parameter is passed to the script, and if not, use the default value 0
if (empty ($offset))
{
$offset = 0;
}
Query results (Here are 20 per page, but you can completely change it)
$result =mysql_query ("SELECT * from Guestbook" desc LIMIT $offset, 5 ");
$result =mysql_query ("SELECT * from Guestbook LIMIT $offset, 5");
Show 5 Records returned
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 ["Times"]);
printf ("Subject: <font color= ' #3366FF ' >%s</font><br>", $data ["title"]);
printf ("Content: <font color= ' #000000 ' >%s</font><br>", $data ["ly"]);
printf ("}
Next, write a 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 </a> n";
}
Calculate the total number of pages required
$pages =ceil ($NR/5); $pages variable now contains the required number of pages
for ($i =1; $i <= $pages; $i + +)
{
$newoffset =5* $i-5;
Print "<a href=" $PHP _self?offset= $newoffset "> $i </a> n";
}
Check if it's the last page
$next = $offset +5;
if ($next < $NR)
{
Print "<a href=" $PHP _self?offset= $next "> Next </a> N";
}
printf ("<a href= ' Javascript:history.back () ' > Return </a>")
?>
</td>
</tr>
</table>
</center>
</div>
</body>
ly.php:
?
Include ("Connect.rec");
$name = $T 1;
$mail = $T 2;
$url = $T 3;
$title = $T 4;
$time = Date ("Y-m-j h:i:s");
$ip = getenv ("REMOTE_ADDR");
$ly = $S 1;
$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 (the message was successful!) ");
printf ("<script language= ' JavaScript ' >");
printf ("location= ' guestbook.php '");
printf ("</script>");
}
Else
{
Echo ("Message failed!") ");
printf ("<a href= ' Javascript:history.back () ' > Return </a>");
}
?>
can go to http://xinai.oso.com.cn/class/guesttap.php view