Xing Lin Alumni (vii) _php Foundation

Source: Internet
Author: User
Guest Book section:
Class Members Guest book: Display message: class/notebook/index.php
?
Session_Start (); Start session
if (!session_is_registered ("Userregister") | | ($userregister = = "")) Check whether registration, such as Userregister or session is null, re-register.
{
echo "<a href=". /index.php ' > Please re-register <BR> ';
Exit
}
?>
<HTML>
<HEAD>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<TITLE> Guest 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);//See how many rows the query results
$max = $row; Total posts
Set each page to display 10, you can set, $p total number of pages, $page the first few pages, $low start from the first few lines, $x read a few lines
if (! $page) {$page = 1;} $page Default value is 1
$p =ceil ($max/10);//$MAX/10 Max Integer
$low =10* ($page-1);
if ($page = = $p && ($max%10) <>0) {$x = ($max%10);} else {$x = 10;} If it is the last page and is not an integer multiple of 10, read the remainder of the $max divided by 10, or take 10
if ($max ==0) {$x = 0;} If there are no posts, $x take 0
$result = mysql_query ("Select * from Notebook" DESC limit $low, $x ", $db);//Follow the time descending query
?>
<table width= "98%" border= "0" cellspacing= "0" cellpadding= "0" height= ">"
<tr>
&LT;TD height= "width=" 34% "></td>
&LT;TD height= "width=" "66%" >
<div align= "center" ></div>"
</td>
</tr>
</table>
<table width= "1" cellspacing= "0" cellpadding= "0" height= "253" bordercolordark= "#FFFFFF" bordercolorlight= "#003399" align= "Center" >
<tr>
&LT;TD height= ">"
<div align= "center" ></div>
<table width= "border=" 0 "cellspacing=" 0 "cellpadding=" 0 "height=" "bgcolor=" #3366FF ">
<tr>
&LT;TD width= "26%" class= "White12" height= "><a href=". /guest.php "class=" White12 "> Home </a>
> Guest Book </td>
&LT;TD width= "48%" class= "White12" height= ">"
<?php
echo "Total number of posts:", $max, "section";
for ($n =1; $n <= $p; $n + +) {
echo "<a href=index.php?page= $n > $n </a>";
}
echo "Page";
?>
</td>
&LT;TD width= "15%" height= "><a href=" addnote.php "></a></td>
&LT;TD width= "11%" height= "" ><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, ' nnote ');
$yresult = mysql_query ("SELECT * from user where user= ' $user '", $db);/Read Member Database
$name =mysql_result ($yresult, 0, ' name ');
$signature =mysql_result ($yresult, 0, ' signature ');/Read personal signature
$email =mysql_result ($yresult, 0, ' email ');
$face =mysql_result ($yresult, 0, ' face ');
$face = '. /image/face/icon '. $face;

Echo ' <table width= ' 100% ' border= ' 0 ' cellspacing= ' 0 ' cellpadding= ' 0 ' height=107 ' bordercolor= ' #FFFFFF ' > <tr Bgcolor= ' #eeeeee ' > ';
echo "<td width= ' 10% ' height= ' bgcolor= ' #eeeeee ' class= ' blue9 ' > </td> ";
echo "<td width= ' 16% ' height= ' bgcolor= ' #eeeeee ' class= ' blue9 ' > Message person: $name </td>";
echo "<td width= ' 41% ' height= ' bgcolor= ' #eeeeee ' class= ' Blue9 ' > published in: $time </td>";
echo "<td width= ' 12% ' height= ' ' bgcolor= ' #eeeeee ' class= ' blue9 ' ><a href= '," mailto ": $email ' ></a></td> ';
echo "<td width= ' 21% ' height= ' class= ' blue9 ' > $ip </td> </tr> <tr> ';
echo "<td colspan= ' 5 ' class= ' purple10 ' height= '" > title: $title </td> </tr> ";
echo "<tr bgcolor= ' #ffffff ' ><td colspan= ' 5 ' class= ' black9 ' height= '" > 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 registration, such as Userregister or session is null, re-register.
{
echo "<a href=". /index.php ' > Please re-register <BR> ';
Exit
}
?>
<HTML>
<HEAD>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<TITLE> Add 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= ">"
<tr>
&LT;TD height= "width=" 34% "></td>
&LT;TD height= "width=" "66%" >
<div align= "center" ></div>"
</td>
</tr>
</table>
<?php
Include (".. /config.php ");
if ($submit) {
$time =date ("Y-year m-month D-day h:i:s A");
$IP = $REMOTE _addr;//message person IP address
$title =strip_tags ($top);
$nnote =nl2br (Strip_tags ($content));//Remove HTML tags First, and then convert line breaks to <br>.
if (! $title | |! $nnote) {//Check to complete
echo "Sorry, you must fill in all the content!<br>". <a href= ' javascript:history.back () ' > Return </a> ';
Exit }
Writing 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 success!" ";
}
?>
<table width= "99%" border= "1" cellspacing= "0" cellpadding= "0" align= "center" bordercolor= "#3366FF" >
<tr bgcolor= "#3366FF" >
&LT;TD width= "81%" class= "White12" height= "><a href=". /.. /main.php "class=" White12 "> Home </a>
> <a href= "index.php" class= "White12" > Guest Book </a> > Add Message </td>
&LT;TD width= "19%" class= "White12" height= "" ><a href= ' index.php ' class= "white12" > View message </a>
</td>
</tr>
<tr>
&LT;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= "M" >
<br>
Content <br>
<textarea name= "Content" cols= "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=&LT;? echo $user?> "class=" White12 "><br>
</a></p>
</BODY>
</HTML>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.